使用 Lucene:如果我进行前缀搜索,为什么会收到太多子句错误? [英] With Lucene: Why do I get a Too Many Clauses error if I do a prefix search?

查看:16
本文介绍了使用 Lucene:如果我进行前缀搜索,为什么会收到太多子句错误?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个应用程序进行前缀搜索有一段时间了.最近索引大小增加了,结果发现某些前缀太多,以至于 lucene 无法处理.它一直给我一个 Too Many Clauses 错误,这非常令人沮丧,因为我一直在查看我的 JAR 并确认包含的代码实际上都没有使用布尔查询.

为什么它不抛出类似 Too Many Hits 的异常?当我肯定只使用前缀查询时,为什么增加布尔查询的静态最大子句整数实际上会使这个错误消失?查询的运行方式是否有一些我不理解的基本内容?是不是偷偷变成了布尔查询?

解决方案

我以前遇到过这个.这与以下事实有关

来自: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)抛出 IOException专家:调用以将查询重写为原始查询.例如,PrefixQuery 将被重写为由 TermQuery 组成的 BooleanQuery.抛出:IO异常

I've had an app doing prefix searches for a while. Recently the index size was increased and it turned out that some prefixes were too darned numerous for lucene to handle. It kept throwing me a Too Many Clauses error, which was very frustrating as I kept looking at my JARs and confirming that none of the included code actually used a boolean query.

Why doesn't it throw something like a Too Many Hits exception? And why does increasing the boolean query's static max clauses integer actually make this error go away, when I'm definitely only using a prefix query? Is there something fundamental to how queries are run that I'm not understanding; is it that they secretly become Boolean queries?

解决方案

I've hit this before. It has to do with the fact that lucene, under the covers, turns many (all?) things into boolean queries when you call Query.rewrite()

From: 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

这篇关于使用 Lucene:如果我进行前缀搜索,为什么会收到太多子句错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆