yotsov
yotsov

Reputation: 775

search for any number in SOLR

How can I set up a SOLR index in a way that allows me to search for any number?

I believe that the following works, more or less:

0* OR 1* OR 2* OR 3* OR 4* OR 5* OR 6* OR 7* OR 8* OR 9*

But it really does not seem to be ideal, and cannot be used as part of double-quoted expressions, etc.

Upvotes: 0

Views: 1642

Answers (1)

MatsLindh
MatsLindh

Reputation: 52802

If you're looking for all documents that contain a token that just is a number, a regular expression search should work:

q=field:/[0-9]+/

If you have tokens in your text that contain a number within other characters (.. but those wouldn't have matched your example), you can add a wildcard before and after matching the numbers:

q=field:/.*[0-9]+.*/

Upvotes: 1

Related Questions