只检索突出显示的字段而不检索整个内容

问题描述:

我想索引pdf,使用solr编写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

您可以在请求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"/> 

我会建议加入& 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