Search code examples
redisredisearch

redissearch tag field fuzzy search


I want to perform fuzzy search in redissearch. Let's say I have "JEREMY,J" in tag field in the database. I want to find JEREM. I tried

FT.SEARCH employee "@FN_Tags:{JEREM}~0.2"

but it doesn't appear to work

Right now the only query that appears to work is processing only TEXT fields:

FT.SEARCH employee "@FN_Fuzzy:%JEREM%"

But trying to do so over tags results in a syntax error

FT.SEARCH employee "@FN_Tags:{%JEREM%}"

Solution

  • Fuzzy search is not supported on tag fields, but you can use prefix search for tags. From the tag field documentation:

    Tags support prefix matching with the regular * character:

    > FT.SEARCH idx "@tags:{ hell* }"
    > FT.SEARCH idx "@tags:{ hello\\ w* }"
    

    You can also use suffix (*tag) or “contains” (*tag*). So for your case

    > FT.SEARCH employee "@FN_Tags:{JEREM*}"
    

    Should work. Hope that helps.