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: [email protected]
For additional commands, e-mail: [email protected]