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

查看:16
本文介绍了带有边界的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 是一个定义跨度查询的抽象类,它检查是否匹配的跨度通过位置检查.具体实现包括检查匹配是否在定义的位置范围内的 SpanPositionRangeQuery 和检查匹配位置的有效负载是否与请求相同的 SpanPayloadCheckQuery.

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天全站免登陆