Using “terms” vs “select?qt=terms” in Solr

十年热恋 提交于 2019-12-22 06:38:18

问题


I have difficulties with the "/terms" request handler using Solr 4.2.0.

Using the web browser the following url returns the list of terms of the fieldName INDUSTRY

http://localhost:8983/solr/collection1/terms?terms.fl=INDUSTRY&terms.prefix=P&terms=true

On the other hand, the following query returns no terms:

http://localhost:8983/solr/collection1/select?qt=terms&terms.fl=INDUSTRY&terms.prefix=P&terms=true

My question is how can I use the "/terms" requestHandler via the "/select" requestHandler?

The log from Solr is the following (if it is of any help to you)

Apr 12, 2013 10:21:55 AM org.apache.solr.core.SolrCore execute
INFO: [collection1] webapp=/solr path=/terms params={terms.fl=INDUSTRY&terms=true&terms.prefix=P} status=0 QTime=5 
Apr 12, 2013 10:22:09 AM org.apache.solr.core.SolrCore execute
INFO: [collection1] webapp=/solr path=/select params={terms.fl=INDUSTRY&terms=true&qt=terms&terms.prefix=P} hits=0 status=0 QTime=0 

回答1:


The following steps solve the above problem.

First, in solrconfig.xml you should remove the "/select" requestHandler and moreover set handleSelect to true.

  <requestDispatcher handleSelect="true" >

Second, reboot Solr and the following query works:

http://localhost:8983/solr/collection1/select?qt=/terms&terms.fl=INDUSTRY&terms.prefix=P&terms=true

IMPORTANT: notice the "/terms" on the qt parameter, using "qt=terms" will not work..




回答2:


In your requesthandler you can add this:

    <lst name="defaults">
         <bool name="terms">true</bool>
    </lst> 

    <arr name="last-components">
        <str>terms</str>
   </arr>

Now you can use the terms.fl to select the terms you want from the select requesthandler:

http://localhost:8983/solr/select?terms.fl=INDUSTRY



来源:https://stackoverflow.com/questions/15966517/using-terms-vs-selectqt-terms-in-solr

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