Skip to content

How can i use OR for numeric ranges? #63

Closed

Description

@onexdrk

Imagine, i have index with field price. I want to find all document where 'price [0 10]' OR 'price [100 1000]'.
Can i do it?

Activity

  1. dvirsky commented on Jun 2, 2017

    @dvirsky
    Contributor

    Yes. you can do something like @price:[0-100]|@price:[200-600]. I haven't tested it but in principle it should work.

  2. onexdrk commented on Jun 2, 2017

    @onexdrk
    Author

    I already test it and it's not working :(

    FT.CREATE indexName SCHEMA price NUMERIC
    FT.ADD indexName doc7 1 FIELDS price 150
    FT.ADD indexName doc8 1 FIELDS price 1500
    FT.SEARCH indexName "@price:[0 200]"
     - correct
    FT.SEARCH indexName "@price:[0 200]|@price:[200 1700]"
    
    (error) Syntax error at offset 14 near '200'
    
  3. dvirsky commented on Jun 2, 2017

    @dvirsky
    Contributor

    Okay, I'm planning a rewrite of the parser in the coming week, this will be added to it.

  4. onexdrk commented on Jun 2, 2017

    @onexdrk
    Author

    Thank's a lot

  5. dvirsky commented on Jun 6, 2017

    @dvirsky
    Contributor

    @onexdrk This has been fixed in the latest master version. You can now also view the query parse tree to make sure it works as expected:

    $ redis-cli --raw
    
    127.0.0.1:6379> ft.explain rd "@date:[0 100]|@date:[300 400]"
    UNION {
      NUMERIC {0.000000 <= x <= 100.000000}
      NUMERIC {300.000000 <= x <= 400.000000}
    }
  6. dvirsky commented on Jun 6, 2017

    @dvirsky
    Contributor

    This fix is included in release 0.17

  7. 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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions