有序邻近搜索
我所说的有序是指文档中 term1 始终位于 term2 之前。
我有两个文件: 1.“我所说的有序是指文档中 term1 始终位于 term2 之前” 2.“我所说的有序,是指文档中 term2 将始终出现在 term1 之前”,
如果我进行查询:
"term1 term2"~Integer.MAX_VALUE
我的结果是: 2 个文档
如何查询以获得一个结果(仅当 term1 出现在 term2 之前时): “我所说的有序是指文档中 term1 始终位于 term2 之前”
有什么想法吗?
By ordered I mean term1 will always come before term2 in the document.
I have two documents:
1. "By ordered I mean term1 will always come before term2 in the document"
2. "By ordered I mean term2 will always come before term1 in the document"
if I make the query:
"term1 term2"~Integer.MAX_VALUE
my results is: 2 documents
How can I query to have one result (only if term1 come before term2):
"By ordered I mean term1 will always come before term2 in the document"
Any Ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您需要使用 SpanNearQuery< /a>
这匹配彼此靠近的跨度。我们可以指定 slop,即插入的不匹配位置的最大数量,以及是否要求匹配按顺序。
然而,Solr 的 dismax 和 edismax 查询解析器使用短语查询,因此匹配始终是无序的。
SurroundQueryParser 支持 Span 查询,并提供一个选项,可以对有序和无序术语进行查询语法发生变化。
尽管此查询解析器仅适用于主干。
更多信息@ http://www.lucidimagination.com/blog /2009/02/22/探索查询解析器/
You would need to use SpanNearQuery
This Matches spans which are near one another. One can specify slop, the maximum number of intervening unmatched positions, as well as whether matches are required to be in-order.
However, the dismax and edismax query parsers with Solr uses the phrase query and hence the match is always unordered.
SurroundQueryParser supports the Span queries with an option to make a query for both ordered and unordered terms with a slight change in the syntax.
Although this Query Parser is available with the trunk only.
More info @ http://www.lucidimagination.com/blog/2009/02/22/exploring-query-parsers/
查找跨度查询。 http://www.lucidimagination.com/blog/2009/07/ 18/the-spanquery/
Look up span query. http://www.lucidimagination.com/blog/2009/07/18/the-spanquery/