我对Solr很新,我正在评估它。我的任务是在书籍集中查找单词并在小范围内将其返回。到目前为止,我将书籍存储在按段落分割的数据库中(通过换行符切换书籍),我进行全文搜索并返回行。
在Solr中,我是否必须这样做,或者我可以添加整本书(以.txt格式),并且每当找到匹配时,返回类似于匹配的内容加上之前的100个单词和之后的100个单词像那样?感谢
答案 0 :(得分:3)
突出显示将进行出价。 http://wiki.apache.org/solr/HighlightingParameters
以下是相关选项:
hl.snippets
The maximum number of highlighted snippets to generate per field.....
hl.fragsize
The size, in characters, of the snippets (aka fragments) created by the highlighter.....
The default value is "100".
hl.mergeContiguous
Collapse contiguous fragments into a single fragment....
对于您所描述的内容,将其设置为从text
字段hl.fl
返回5(或人类可以妥善处理的任何内容)片段;每个片段的长度在单词/短语周围400个字符(我的近似100个单词)。
另请参阅hl.regex.slop
以构建短语的片段,并hl.simple.pre/hl.simple.post
标记。