lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ian Lea <>
Subject Re: Opposite of SpanFirstQuery - Searching for documents by last term in a field
Date Tue, 11 Dec 2012 16:04:30 GMT
The javadoc for SpanFirstQuery says it is a special case of
SpanPositionRangeQuery so maybe you can use the latter directly,
although you might need to know the position of the last term which
might be a problem.

Alternatives might include reversing the terms and using SpanFirst or
adding a special "thisistheend" token to each field and using
SpanNearQuery for dog and thisistheend with suitable value for slop
and inOrder = true.

Or take the last term and index it in a separate field so you can just
search for lastterm: dog.


On Tue, Dec 11, 2012 at 3:19 PM, Hasenberger, Josef
<> wrote:
> Hi,
> I wonder if there is a way to use a SpanQuery to find documents with fields that end
with a certain term.
> Kind of the oppoisite of SpanFirstQuery, i.e. "SpanLastQuery", if you want.
> What I would like to do:
> Find terms that are at the end of a field.
> Example:
> Assume the following field content: "the quick brown fox jumps over the lazy dog".
> I would like to find all documents that have "dog" at the end of the field.
> Any idea, how I can achieve this?
> Thanks a lot and best regards,
> Josef

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message