WildcardQuery wq1 = new WildcardQuery(new Term("id", "*hank*"));
WildcardQuery wq2 = new WildcardQuery(new Term("id", "*todd*"));
bq = new BooleanQuery();
bq.add(wq1, Occur.SHOULD);
bq.add(wq2, Occur.SHOULD);
query = bq;
但使用萬用字元,會丟TooManyClauses的exception
org.apache.lucene.search.BooleanQuery$TooManyClauses: maxClauseCount is set to 1024
/** Set the maximum number of clauses permitted per BooleanQuery.
* Default value is 1024.
*
TermQuery clauses are generated from for example prefix queries and
* fuzzy queries. Each TermQuery needs some buffer space during search,
* so this parameter indirectly controls the maximum buffer requirements for
* query search.
*
When this parameter becomes a bottleneck for a Query one can use a
* Filter. For example instead of a {@link RangeQuery} one can use a
* {@link RangeFilter}.
*
Normally the buffers are allocated by the JVM. When using for example
* {@link org.apache.lucene.store.MMapDirectory} the buffering is left to
* the operating system.
*/
0 意見:
張貼留言