获取 Solr 突出显示的术语列表
当我搜索“鱼”这个词时,我会得到包含该词及其变体的文档列表。如果我打开突出显示,我可能会看到如下所示的片段: 法律要求任何人在公共湖泊钓鱼
...
我想向用户展示上面的代码片段,效果很好顺便说一句,但我还想向用户展示完整的单词列表,如果我显示所有片段,这些单词也会突出显示。
例如,我希望能够向用户展示以下内容:
第 18.32A 条 - 狩猎和钓鱼 ...法律要求任何人
在公共湖泊钓鱼
... 文件还包含:鱼、钓鱼、渔夫
除了让 solr 突出显示整个文档然后我解析文档查找 em 标签并构建突出显示的单词列表之外,还有其他方法可以获取该单词列表吗?
When I search for the word "fish" I get back a list of documents containing that word and variants of that word. If I turn on highlighting I might see a snippet that looks like this:
The law requires that anyone <em>
fishing</em>
in public lakes...
I would like to show the user the above snippet, which works just fine by the way, but I would also like to show the user a complete list of words that would also have been highlighted had I shown all snippets.
For example I would like to be able to show the user the following:
Section 18.32A - Hunting and Fishing
...The law requires that anyone<em>
fishing</em>
in public lakes...
Document also contains: Fish, Fishing, Fisherman
Is thee a way to get that list of words other than having solr highlight the entire document and then me parsing the document looking for em tags and building a list of highlighted words?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我会研究片段大小 (hl.fragsize)、同义词 (synonym.txt) 或词干提取(可以帮助处理单词的变体)以找到解决方案。您可以将“fish”、“fishing”、“fished”设置为同义词,含义相同。确保您了解展开全部的工作原理以及您是否希望搜索相互替换。还要确保您知道是否对同义词文件建立索引或使用它进行查询。不要在索引和查询时都使用同义词。还有一个开关可以在突出显示中启用多个匹配。
I would investigate frag size (hl.fragsize), synonyms (synonym.txt), or stemming (can help with variations of a word) to find a solution. You can set fish, fishing, fished to all mean the same in synonyms. Ensure you understand how the expand all works and whether you want the search to replace each with the other. Also ensure you know whether to index the synonym file or query with it. Do not use synonyms at both index and query time. There is also a switch to enable multiple matches in highlighting.