sama
sama

Reputation: 1

Lucene - How to find numbers in String field

I have a String field in Lucene (4.7) and I want to find in this field number that is different from a number I have. How can I do it?

For example, the field include "abc345 + kl908" and I want to find "abc" followed by any number that is different from 123. Especially I don't want it to find "abcde" because "de" is not a number.

Is there a query that can find it?

Thanks a lot!

Upvotes: 0

Views: 204

Answers (1)

Alessandro Suglia
Alessandro Suglia

Reputation: 1927

What about using a RegexQuery?

In this way you can specify a regular expression that it's able to validate the field following your constraints.

Upvotes: 2

Related Questions