2

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 Answers1

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*
Guy Korland
  • 9,139
  • 14
  • 59
  • 106
  • Thanks @Guy for replying. Don't you think that it will increase memory consumption? If we have 1000 integer fields then we are going to make them double i.e. 2K fields. – Rishabh Kabra Apr 27 '22 at 20:40
  • It might increase the memory since you need to index twice in two modes, but it won't duplicate the data in Redis key space since it's just an alias to the same field. – Guy Korland Apr 28 '22 at 06:27