'How can we perform "Prefix Matching" in Redisearch over numbers?
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
Solution 1:[1]
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*
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Guy Korland |
