问题描述
有没有一种方法可以执行受限制的邻近搜索,而不是由固定数量的标记限制,而是由2种某种形式的标记标记限制?例如,要实现以单个句子或段落为界的邻近查询?显然,分析器必须支持它,但是以前已经做到了,如何做到?
Is there a way to perform a proximity search that is bounded, not by a fixed number of tokens, but by 2 marker tokens of some kind? For example, to implement proximity queries that are bounded inside as single sentence or paragraph? Obviously the analyzer has to support it, but has this been done before, and how?
推荐答案
SpanPositionCheckQuery
是定义跨度查询的抽象类,该查询检查是否匹配的跨度将通过位置检查.具体的实现包括SpanPositionRangeQuery
检查匹配项是否在定义的位置范围内,以及SpanPayloadCheckQuery
检查匹配位置的有效载荷是否与请求的相同.
SpanPositionCheckQuery
is an abstract class that defines a span query, which checks ifthe matched span passes a check for position. Concrete implementations include SpanPositionRangeQuery
that checks if the match is in a defined range of positions and SpanPayloadCheckQuery
that checks if the payloads of the matched positions are the same as requested.
也许您可以通过为每个标记分配一个有效负载(指示它属于哪个句子/段落)(并带有一个计数器),然后检查匹配范围内的所有有效负载是否相等,来实现您想要的目标?我认为,扩展课堂以实现这一目标应该很简单.
Maybe you could achieve what you want by assigning a payload to each token indicating to which sentence/paragraph it belongs (with a counter) and then checking if all the payloads of the matched span are equal? I think that extending above class to achieve it should be straightforward.
这篇关于有边界的Lucene邻近搜索?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!