1

我想使用 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

4

2 回答 2

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

于 2013-05-14T18:10:51.750 回答
0

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

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

SOLR 字段参数

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

<field name="content" type="text_general" indexed="false" stored="false" multiValued="true"/>
于 2013-05-14T21:00:49.110 回答