WildcardQuery error in Solr

后端 未结 7 2343
花落未央
花落未央 2021-02-20 16:47

I use solr to search for documents and when trying to search for documents using this query \"id:*\", I get this query parser exception telling that it cannot parse

7条回答
  •  夕颜
    夕颜 (楼主)
    2021-02-20 17:30

    The following Solr issue is a request to be able to configure the default lucene query parser. https://issues.apache.org/jira/browse/SOLR-218

    In this issue you can find the following description how to 'patch' Solr. This modification would allow you to start queries with a *.

    Jonas Salk: I've basically updated only one Java file: SolrQueryParser.java.

    public SolrQueryParser(IndexSchema schema, String defaultField) { 
        ... 
        setAllowLeadingWildcard(true); 
        setLowercaseExpandedTerms(true); 
        ... 
    }
    
     ...
    
    public SolrQueryParser(QParser parser, String defaultField, Analyzer analyzer) {
        ... 
        setAllowLeadingWildcard(true); 
        setLowercaseExpandedTerms(true);
        ... 
    }
    

    I'm not sure if setLowercaseExpandedTerms is needed...

提交回复
热议问题