Skip to content
Advertisement

Lucene LongPoint Range search doesn’t work

I am using Lucene 8.2.0 in Java 11.

I am trying to index a Long value so that I can filter by it using a range query, for example like so: +my_range_field:[1 TO 200]. However, any variant of that, even my_range_field:[* TO *], returns 0 results in this minimal example. As soon as I remove the + from it to make it an OR, I get 2 results.

So I am thinking I must make a mistake in how I index it, but I can’t make out what it might be.

From the LongPoint JavaDoc:

An indexed long field for fast range filters. If you also need to store the value, you should add a separate StoredField instance. Finding all documents within an N-dimensional shape or range at search time is efficient. Multiple values for the same field in one document is allowed.

This is my minimal example:

JavaScript

Advertisement

Answer

I found the solution to my problem.

I was under the impression that the query parser could just parse any query string correctly. That doesn’t seem to be the case.

Using

JavaScript

returned the correct result.

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement