2013-05-14 42 views
1

我想索引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

回答

0

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