Is it possible to use regex expressions on long fields?

I have long field in my mapping . the field has some values but in that i want the documents of long field that has 130 (i.e i want all the documents that has the long field starting with 130) .

Like below Scenario:

Doc1                                        Doc2                                       Doc3
long field:130056                    long field:130556                                     long field:120336

If i search for long field =130 * in my query, i have to get Doc 1 &2 in my output.

IS this possible in ES?

If you mean the numeric datatype long then the answer is No, you cannot use regular expressions on that field. You can add another string field with the same value to each doc to be able to use prefix or regex searches though.

I expect it'd be easier to use a bunch of range queries in bool should clauses. It won't be faster, but, depending on what you want, it'd be easier.

If you are always going to be doing these prefix searches I'd suggest looking at the completion suggester and edge_ngram analyzers. They both are for fast prefix searching but have different time, memory, and result tradeoffs.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.