获取 Solr 突出显示的术语列表

发布于 2025-01-07 13:44:42 字数 458 浏览 0 评论 0原文

当我搜索“鱼”这个词时,我会得到包含该词及其变体的文档列表。如果我打开突出显示,我可能会看到如下所示的片段: 法律要求任何人在公共湖泊钓鱼...

我想向用户展示上面的代码片段,效果很好顺便说一句,但我还想向用户展示完整的单词列表,如果我显示所有片段,这些单词也会突出显示。

例如,我希望能够向用户展示以下内容:

第 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

幼儿园老大 2025-01-14 13:44:43

我会研究片段大小 (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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文