Lucene proximity search with boundaries?

前端 未结 1 2060
伪装坚强ぢ
伪装坚强ぢ 2021-01-21 04:25

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 t

相关标签:
1条回答
  • 2021-01-21 04:47

    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.

    0 讨论(0)
提交回复
热议问题