solr - set fields as default search field - Using

2019-07-28 18:41发布

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?

标签: solr solr4
3条回答
对你真心纯属浪费
2楼-- · 2019-07-28 18:54

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>
查看更多
Rolldiameter
3楼-- · 2019-07-28 18:55

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>
查看更多
Explosion°爆炸
4楼-- · 2019-07-28 19:06

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>
查看更多
登录 后发表回答