有边界的Lucene邻近搜索? [英] Lucene proximity search with boundaries?

查看:102
本文介绍了有边界的Lucene邻近搜索?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有一种方法可以执行受限制的邻近搜索,而不是由固定数量的标记限制,而是由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 is an abstract class that defines a span query, which checks if the 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邻近搜索?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆