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
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.