如何从Sphinx搜索引擎获取搜索词位置?
我使用 Sphinx 来索引 HTML 页面,为标题、描述等赋予不同的权重。我正在寻找一种方法,从 Sphinx 获得的结果中获取搜索词在页面中的位置。
意思是,如果单词集是“堆栈溢出程序”并且我有 5 个匹配的文档,那么每个文档都是匹配的,因为它至少包含单词集中的一个单词。
问题是:我如何知道文档中每个单词的位置?例如,我想知道文档 1 是否返回,因为它的标题中包含“溢出”,描述中包含“堆栈”。
我看到返回的结果具有一定的权重(例如 3780),但我无法从中得出在哪里找到哪个单词的结论。
多谢!
I use Sphinx to index HTML pages, giving different weights to title, description, etc. I'm looking for a way to get the search words location in the page from the results that I get from Sphinx.
Meaning, if the wordset is "stack overflow program" and I have 5 documents that match, each of them was a match because it contained at least one word from the wordset.
The question is: how do I know where each word was found in a document? For example, I want to know if document 1 returned because it contained "overflow" in the title and "stack" in the description.
I see that the result returns with a certain weight (3780, for example) but I can't conclude from that on what word was found where.
Thanks a lot!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您必须(以某种方式)以编程方式获取结果,然后您可以调用 在内容上构建摘录。然后,Sphinx 将为您提供一个 HTML 块,其中包含找到的文本的相对位置。
You'll have to (somehow) get the results back programmatically, and then you can call BuildExcerpts on the contents. Sphinx will then give you an HTML block with the relative positions of the found text.