I would like to get Lucene text search results in the description, but only from the documents in the set ids
.
You need to use BooleanQuery
.
If you create a query using QueryParser
, use:
+(id:6345 id:5759 id:333 ...) +(description:"blah*")
If you create Query
programmatically, then the code will look something like this:
BooleanQuery ids = new BooleanQuery();
ids.add(new TermQuery(new Term("id", "6345")), SHOULD);
ids.add(new TermQuery(new Term("id", "5759")), SHOULD);
ids.add(new TermQuery(new Term("id", "333")), SHOULD);
BooleanQuery resultQuery = new BooleanQuery();
resultQuery.add(new PrefixQuery(new Term("description", "blah")), MUST);
resultQuery.add(ids, MUST);
A set ids
maybe tens of thousands.
BooleanQuery
(. org.apache.lucene.search.BooleanQuery#maxClauseCount
). , BooleanQuery.setMaxClauseCount()
. .
Lucene , , ? - ?
, - , . , ( ).
, , Lucene ( ). Lucene . , , Lucene, " " Lucene.
Lucene , . , , .