Skip to content

Wildcard Search #27

Closed
Closed

Description

@RupertAvery

Is it possible to query partial words with a wildcard query, such as "he*" for "hello"?

Activity

  1. dvirsky commented on Feb 20, 2017

    @dvirsky
    Contributor

    Currently - not directly, although it might change soon.

    But you can do it in conjunction with the auto-suggestion API. What you can do is build a dictionary with FT.SUGADD, and get prefix suggestions with FT.SUGGET, and pass those to the search as an OR query. i.e.:

    > FT.SUGADD terms hello 1.0
    > FT.SUGADD terms help 1.0
    ...
    

    and in your code (writing python/pseudo code here):

    terms = client.get_suggestions('terms', 'he')
    result = client.search("|".join(terms))

    But I intend to change the main index dictionary into a prefix tree, which will allow doing this automatically as you describe.

    Will the above method do for now? You can of course implement it in Lua to make things atomic.

  2. RupertAvery commented on Feb 20, 2017

    @RupertAvery
    Author

    Unfortunately, no. I have a set of denormalized data I would like to cache in redis and I would really like to be able to query it directly without having to set it up myself, as that kind of defeats the purpose of putting it there.

  3. dvirsky commented on Feb 20, 2017

    @dvirsky
    Contributor

    Can you explain further?

  4. RupertAvery commented on Feb 20, 2017

    @RupertAvery
    Author

    Well a full-text search is probably not the best way to achieve this, but suppose i have a list of names, and I want to do a query on a name that starts with or contains "Foo", without having to add "Foobar", "Foobaz", and "Foogle" to the suggestions for Foo, because I could search for "Foob" or "Foog" as well and I'd have to add those names as suggestions for Foob and Foog.

  5. dvirsky commented on Feb 20, 2017

    @dvirsky
    Contributor

    @RupertAvery Oh, in that case I might be able to help you after all! :)

    I've also written a module called Secondary that allows you to do just that, with an SQL like syntax. You can use it on HASH keys or directly as a data type. Basically you can do:

    IDX.FROM users_name WHERE "name LIKE 'foo%'" HGETALL $
    

    And you can create indexes on multiple fields, etc.

    Have a look: https://github.com/RedisLabsModules/secondary

  6. RupertAvery commented on Feb 20, 2017

    @RupertAvery
    Author

    I'll take a look at it, thanks!

  7. dvirsky commented on Feb 22, 2017

    @dvirsky
    Contributor

    @RupertAvery did you look at the other module? have you tried it?

  8. runningmaster commented on Sep 13, 2017

    @runningmaster

    @dvirsky, do you have a plan to add in RediSearch something like that:

    SELECT * FROM table WHERE Column LIKE '%foo%';
    SELECT * FROM table WHERE Contains(Column, "foo");
    SELECT * FROM table WHERE Column CONTAINING "foo";
    SCAN 0 MATCH *foo*
    ... etc.

    For example, I need to find all words containing foo:

    foo
    foobar
    barfoo
    bazfoobar
    
  9. runningmaster commented on Sep 13, 2017

    @runningmaster

    To be more precise, I need something similar Simple phrase query - hello AND world

    hello world
    

    but with "containing" feature

    *hello* *world*
    
    hello world
    world hello
    foo hello bar world
    foohello barworld
    hellofoo worldbar
    foobarhelloworld
    fooworldbarhello
    ...etc.
    
  10. dvirsky commented on Sep 15, 2017

    @dvirsky
    Contributor

    hi. at the moment we only support prefix queries. you can pre-split your terms if you want any suffix. indexing all suffixes of any term with the current data structure would be very costly.

  11. added a commit that references this issue on Oct 7, 2020
  12. added a commit that references this issue on Nov 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions