5

我对使用 Solr 4.2.0 的“/terms”请求处理程序有困难。

使用 Web 浏览器,以下 url 返回 fieldName INDUSTRY 的术语列表

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

另一方面,以下查询不返回任何术语:

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

我的问题是如何通过“/select” requestHandler 使用“/terms” requestHandler?

Solr 的日志如下(如果对您有任何帮助)

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 
4

2 回答 2

4

以下步骤解决了上述问题。

首先,在 solrconfig.xml 中,您应该删除“/select” requestHandler 并将 handleSelect 设置为 true。

  <requestDispatcher handleSelect="true" >

其次,重新启动 Solr 并且以下查询有效:

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

重要提示:注意 qt 参数上的“/terms”,使用“qt=terms”将不起作用..

于 2013-04-12T09:45:45.950 回答
1

在您的请求处理程序中,您可以添加以下内容:

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

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

现在您可以使用 terms.fl 从选择请求处理程序中选择您想要的术语:

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

于 2013-11-15T10:46:54.517 回答