【问题标题】:Retrieving only highlighted solr field and not the whole content仅检索突出显示的 solr 字段而不是全部内容
【发布时间】:2013-05-14 17:19:01
【问题描述】:

我想使用 solr 索引 pdf、word 文档。 word / pdf 文档的全部内容都出现在搜索响应和突出显示的片段中。内容很长,由于内容长度,我想在搜索响应中避免它。

是否可以仅获取内容字段的突出显示片段?

这是搜索查询

http://localhost:8080/solr4x/collection1/select?q=Scripting&wt=xml&hl=true&hl.fl=content

这是架构

<field name="content" type="text_general" indexed="false" stored="true"multiValued="true"/>

<field name="text" type="text_general" indexed="true" stored="false" multiValued="true"/>

 <copyField source="content" dest="text"/>

我正在使用 solr 4.3

【问题讨论】:

    标签: solr solr4


    【解决方案1】:

    我建议将 &hl.fragsize=100(片段大小)添加到您的查询中。默认情况下它应该是 100,但我不确定它为什么会为您提取全部内容。将不得不查看您的 solrconfig.xml。

    尝试将您的搜索查询更改为:

    http://localhost:8080/solr4x/collection1/select?q=Scripting&wt=xml&hl=true&hl.fl=content&hl.fragsize=100
    

    这是有关 fragsize 的文档:http://wiki.apache.org/solr/HighlightingParameters#hl.fragsize

    【讨论】:

      【解决方案2】:

      您可以在请求 url 中指定要返回的字段:

      http://localhost:8080/solr4x/collection1/select?q=Scripting&wt=xml&hl=true&hl.fl=content&fl=text
      

      SOLR field parameter

      或者您无法存储内容字段(尽管不确定既不存储也不索引的字段的有用性):

      <field name="content" type="text_general" indexed="false" stored="false" multiValued="true"/>
      

      【讨论】:

        猜你喜欢
        • 2015-11-27
        • 1970-01-01
        • 2014-10-23
        • 1970-01-01
        • 2013-07-05
        • 2012-12-01
        • 2012-10-14
        • 2013-05-22
        • 1970-01-01
        相关资源
        最近更新 更多