lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Chetan Shah <chetankrs...@gmail.com>
Subject TermsFilter Usage Question
Date Thu, 26 Feb 2009 18:45:14 GMT

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-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org


Mime
View raw message