solr - set fields as default search field - Using EdisMax

对着背影说爱祢 提交于 2020-01-05 10:28:44

问题


The following query works well for me

http://...:8983/solr/vault/select?q=White&defType=edismax&qf=VersionComments+VersionName

returns all the documents where version comments includes White

I try to omit the qf containing the fields names : In solr config I write

<requestHandler name="/select" class="solr.SearchHandler">
<!-- default values for query parameters can be specified, these
     will be overridden by parameters in the request
  -->
 <lst name="defaults">
   <str name="echoParams">explicit</str>
   <int name="rows">10</int>
   <str name="df">PackageName</str>
   <str name="df">Tag</str>
   <str name="df">VersionComments</str>
   <str name="df">VersionTag</str>
   <str name="df">VersionName</str>
   <str name="df">SKU</str>
   <str name="df">SKUDesc</str>
 </lst>

I restart the solr and create a full import.
Then I try using

 http://...:8983/solr/vault/select?q=White&defType=edismax

But I dont get the document any as answer.
What am I doing wrong?


回答1:


df is the default field and will only take effect if the qf is not defined and its a single definition field in the configuration.

You can check the below configuration with qt=edismax parameter :-

<requestHandler name="edismax" class="solr.SearchHandler" >
    <lst name="defaults">
        <str name="defType">edismax</str>
        <str name="echoParams">explicit</str>
        <str name="df">PackageName Tag VersionComments ....</str>
    </lst>
</requestHandler>



回答2:


You can use qf (query field) with weight indication.

<requestHandler name="/select" class="solr.SearchHandler">
<!-- default values for query parameters can be specified, these
     will be overridden by parameters in the request
  -->
 <lst name="defaults">
   <str name="echoParams">explicit</str>
   <int name="rows">10</int>
   <!--
   [....]
   -->
   <str name="qf">PackageName^40.0 Tag^10.0 VersionComments^5.0 VersionTag^4.0</str>
   <!--
   [....]
   -->
 </lst>
</requestHandler>



回答3:


Solr 4.8.1 We can make default as follows. by editing solrconfig.xml

<requestHandler name="/clustering" startup="lazy" enable="${solr.clustering.enabled:false}" class="solr.SearchHandler">    
    <lst name="defaults">

        <!-- Configure the remaining request handler parameters. -->
        <str name="defType">edismax</str>
        <str name="qf">
            text^0.5 features^1.0 name^1.2 sku^1.5 id^10.0 manu^1.1 cat^1.4
        </str>

        <str name="q.alt">*:*</str>
        <str name="rows">10</str>
        <str name="fl">*,score</str>
    </lst>
        <arr name="last-components">
          <str>clustering</str>
        </arr>
</requestHandler>


来源:https://stackoverflow.com/questions/17941259/solr-set-fields-as-default-search-field-using-edismax

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