Span Queries Near a Known Token Index

Is there a way to do a span query near a particular token index?

For example, is it possible to find all documents that mention "foo" within ten tokens of the start of the document? Or more generally, is it possible to find all documents that contain "foo" within X tokens of the Yth token in the document?

There is no span query that does it directly as it is a more common use-case to reason on relative positions of tokens. However, the information that is needed to find tokens near a certain absolute position is available in the Lucene index so it would be possible to implement such span queries.

Thanks for the response, that's what I thought, but wanted to double check. This would be a really nice feature.

FYI, I opened a feature request which has a richer explanation of the motivation and use-cases:

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.