3

Is there any way to restrict RediSearch results by a list of document IDs, which would be specified in the request?

e.g. something like FT.SEARCH cars fast @id:{100,200,300} would return only fast cars having ID 100, 200, or 300.

mahemoff
  • 44,526
  • 36
  • 160
  • 222

1 Answers1

4

Yes, there's the INKEYS keyword.

> FT.SEARCH cars "fast" INKEYS 3 100 200 300

See https://oss.redislabs.com/redisearch/Commands/#ftsearch

Not_a_Golfer
  • 47,012
  • 14
  • 126
  • 92
  • I am not understanding this at all. Could you please explain. This searches for those IDs on what field of the index? – ficuscr May 01 '21 at 18:15
  • 1
    @ficuscr the primary id of the documents, i.e the actual redis key. – Not_a_Golfer May 01 '21 at 22:00
  • Ahh. I see. I was looking for a way to filter on documents with a certain category id, not unique. I'll keep searching, or open another question. Thanks. – ficuscr May 01 '21 at 23:51
  • @ficuscr that's not a problem. See tag fields. https://oss.redislabs.com/redisearch/Tags/ – Not_a_Golfer May 02 '21 at 04:49
  • 1
    This worked. Numeric index. `FT.SEARCH lot_idx "polaris (@category:[1 1] | @category:[33 33] | @category:[70 70])"` – ficuscr May 04 '21 at 16:50
  • While that worked, you were right, tags were a much better option and what I ended up using. I was hung up on the value being numeric and not understanding the use cases for tags. – ficuscr May 14 '21 at 06:28