Redisearch: How can i use OR for numeric ranges?

Created on 2 Jun 2017  路  6Comments  路  Source: RediSearch/RediSearch

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?

bug enhancement

All 6 comments

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

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'

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

Thank's a lot

@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}
}

This fix is included in release 0.17

Was this page helpful?
0 / 5 - 0 ratings

Related issues

dme-development picture dme-development  路  8Comments

lumina7 picture lumina7  路  6Comments

chuckyz picture chuckyz  路  9Comments

luistrigueiros picture luistrigueiros  路  6Comments

tw-bert picture tw-bert  路  4Comments