Since Redisearch 2.0 works on existing data, what is the proper way to handle queries where data isn’t escaped at insertion?
For example, I have many text values such as item-1, item-2, s-1, s-2 where I want to be able to find that exact phrase, but other times I may just search for what’s before the dash.
When I attempt FT.SEARCH for s-2 or s-2 to find the exact phrase match I get no results.
@u66NH9MJQ1dv you need to define the field on ft.create with the proper type. For example if you want exact match you probably need to define the field as a TAG field (https://oss.redislabs.com/redisearch/Tags/). Also notice that you need to escape the ‘-’ in the query, i.e, on redis-cli the query need to look like: ft.search s\\-1
Yes this is because ‘-’ is a token that we split in our tokenizer so if you indexed as TEXT you will not be able to find it. We are planing to allow to customize to tokenizer and give your own tokenizations chars, but its only will be available in future versions.
Thanks @meirsh , this makes sense and I’ve switched to use TAG.
The following is giving an error when I try to search two TAGs, even though both work separately. My example appears to match the documentation. Has something changed here for 2.0 or am I missing something more obvious?
@u66NH9MJQ1dv on the redis-cli you need to wrap the query with ‘"’ so it will not be spitted to two argument:
127.0.0.1:6379> FT.SEARCH tasks “@movefrom:{s\-2} @moveto:{s\-1}”
1) (integer) 0