With Lucene: Why do I get a Too Many Clauses error if I do a prefix search?

前端 未结 3 1261
慢半拍i
慢半拍i 2021-01-12 07:19

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.

3条回答
  •  梦谈多话
    2021-01-12 08:04

    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
    

提交回复
热议问题