Lucene.Net TermRangeQuery: How to exclude string values outside range

28 Views Asked by At

Suppose I have a collection of values stored in a Lucene index:

"Item-1-1"
"Item-1-2"
"Item-1-3"
...
"Item-1-10"
"Item-1-11"
"Item-1-12"

Suppose I want to get a range of items between "Item-1-1" and "Item-1-3" inclusively. If I use a TermRangeQuery, it will return "Item-1-1" just fine but it will also return "Item-1-10", "Item-1-11", etc. Is there a way to exclude values outside the search range?

One solution is to add an incrementing id to each item in the index. Then, at search time, find the min and max ids that corresponds to the query and then perform a range query on the id. But I am curious if there is a solution that works on just the string values (without the need for an index field).

0

There are 0 best solutions below