what is solr's default query parser

断了今生、忘了曾经 提交于 2019-12-23 20:08:57

问题


i am confused by these words in the solr document:

https://cwiki.apache.org/confluence/display/solr/The+Standard+Query+Parser

Before Solr 1.3, the Standard Request Handler called the standard query parser as the default query parser. In versions since Solr 1.3, the Standard Request Handler calls the DisMax query parser as the default query parser.

https://cwiki.apache.org/confluence/display/solr/The+DisMax+Query+Parser

The q parameter does not support wildcard characters such as *.

so i download solr 4.7.2, unzip it

checking that i have

  <requestHandler name="/select" class="solr.SearchHandler">

in solr-4.7.2/example/solr/collection1/conf/solrconfig.xml, by default.

then, i index this document

<?xml version="1.0"?>
<add>
  <doc boost="1.0">
        <field name="id">item1</field>
    </doc>
</add>

but

http://localhost:8983/solr/collection1/select?q=id:it*

finds the document,

http://localhost:8983/solr/collection1/select?q=id:it*defType=dismax

finds no item

so looks like standard query parser is the default instead of the dismax query parser?


回答1:


The default is defined in your solrconfig.xml file. The default solrconfig.xml file that comes with 4.7.2 has the following entry:

edismax

This means that the default is the extended dismax query parser. http://wiki.apache.org/solr/ExtendedDisMax




回答2:


It looks me standard query parser is the default instead of the dismax query parser. But we can specify default query parser for any solr(ver 4 ) request handler.

below is some config entry from solrConfig.xml file

    <requestHandler name="/query" class="solr.SearchHandler">
         <lst name="defaults">
           <str name="echoParams">explicit</str>
           <int name="rows">20</int>
           <str name="defType">edismax</str>
           <str name="wt">json</str>
         </lst>
      </requestHandler>



回答3:


I can't add a comment to your initial question, but nagendra has it essentially right, although you are using /query rather than /select which he is defining as a requestHandler in his segment from solrconfig.xml.

You are also missing an & in your url before your defType so it will be treated as part of your search string, not as a separate parameter.

http://localhost:8983/solr/collection1/select?q=id:it*&defType=dismax

will not return results because it will use the dismax parser which doesn't support *, but,

http://localhost:8983/solr/collection1/select?q=id:it*&defType=edismax

will give a result as it is instead using edismax.

As of the time of writing the page you refer to has been replaced with the following which refers to the standard query parser being the default, so perhaps it has reverted?

https://lucene.apache.org/solr/guide/6_6/the-standard-query-parser.html



来源:https://stackoverflow.com/questions/23115781/what-is-solrs-default-query-parser

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!