Probably a silly question, but are you *also* sure that you have documents with catetoryType:xyz AND the values you are asking for in searchCriteria? I'd guess that you could also check this out in Luke with a simple +contests:blah +categoryType:xyz as a quick sanity check.
The other thing it'd be interesting to do is prove that categoryFilter had some bits turned on in its BitSet (or DocIdSet). Best Erick On Thu, Feb 26, 2009 at 1:45 PM, Chetan Shah <chetankrs...@gmail.com> wrote: > > Why is this code not returning any results? > > //Create the query and search > QueryParser queryParser = new QueryParser("contents", new > StandardAnalyzer()); > Query query = queryParser.parse(searchCriteria); > > Term aTerm = new Term("categoryType"); > TermsFilter categoryFilter = new TermsFilter(); > aTerm = aTerm.createTerm("xyz"); > categoryFilter.addTerm(aTerm); > > TopDocs topDocs = indexSearcher.search(query, categoryFilter, > Constants.MAX_HITS); > /** above line works if I null the filter **/ > > ScoreDoc scoreDoc[] = topDocs.scoreDocs; > int numDocs = scoreDoc.length; > if (numDocs > 0) results = scoreDoc; > > > If I do this for the line /**works...*// I get valid results. > TopDocs topDocs = indexSearcher.search(query, null, Constants.MAX_HITS); > > The field "categoryType" is stored in the index. and I have confirmed via > Luke that "xyz" value is stored in the "categoryType" field. > > Would highly appreciate if you can let me know what am I doing wrong here. > -- > View this message in context: > http://www.nabble.com/TermsFilter-Usage-Question-tp22230841p22230841.html > Sent from the Lucene - Java Users mailing list archive at Nabble.com. > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: java-user-unsubscr...@lucene.apache.org > For additional commands, e-mail: java-user-h...@lucene.apache.org > >