I have this search query in Lucene
String searchVal = "+(narr:foo narr:bar)" + " +(narr:foo2 narr:bar2)" + " -(narr:foo3 narr:bar3)";
IndexReader reader = luceneUtils.getIndexReader();
IndexSearcher searcher = luceneUtils.getIndexSearcher();
Query query = new QueryParser("narr", new EnglishAnalyzer()).parse(searchVal);
TopDocs topDocs = searcher.search(query, reader.numDocs());
In the sample code above, topDocs
variable holds the result set of Lucene query.
How can I create another Lucene query that searches only in documents retrieved from the previous query. i.e. How can I execute query on topDocs
instead of executing it on all indexed documents?