How can we perform "Prefix Matching" in Redisearch over numbers?

522 views Asked by At

I have a field marks. It is a numeric field so, as per Redis, we should perform search something like this:

@marks:[10 5000]

or

@marks:[10 inf]

But I want functionality as above and in addition with functionality as below

@marks:10*

So, I will get set of marks something like this: {101, 102,..., 1011, 1012, 1021, 1022,..., 10011,...}

Is it possible in Redisearch as I could not find any way to perform @marks:10* on numeric fields

1

There are 1 answers

2
Guy Korland On

You can index the same field with two different alias names e.g.

FT.CREATE myidx ON HASH PREFIX 1 doc: SCHEMA marks as marks-txt TEXT name as marks-num NUMERIC

Then you can do both:

@marks-num:[10 5000]

And

@marks-txt:10*