我有一个应用程序进行前缀搜索有一段时间了。最近索引大小增加了,结果发现一些前缀太多了,lucene 无法处理。它不断向我抛出 Too Many Clauses错误,这非常令人沮丧,因为我一直在查看我的 JAR 并确认所包含的代码实际上都没有使用 bool 查询。
为什么它不抛出像 Too Many Hits 这样的异常?为什么增加 bool 查询的静态 max 子句整数实际上会使这个错误消失,当我绝对只使用前缀查询时?是否有一些我不理解的查询运行方式的基本原理;是不是它们偷偷变成了 bool 查询?
最佳答案
我以前打过这个。它与以下事实有关,即在调用 Query.rewrite() 时,lucene 在幕后将许多(所有?)事物转换为 bool 查询
发件人:http://web.archive.org/web/20110915061619/http://lucene.apache.org:80/java/2_2_0/api/org/apache/lucene/search/Query.html
public Query rewrite(IndexReader reader)
throws IOException
Expert: called to re-write queries into primitive queries.
For example, a PrefixQuery will be rewritten into a
BooleanQuery that consists of TermQuerys.
Throws:
IOException
关于exception - 使用 Lucene : Why do I get a Too Many Clauses error if I do a prefix search?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8532/