Search code examples
filterredisearch

Filter on IDs with RediSearch


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.


Solution

  • Yes, there's the INKEYS keyword.

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

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