Search code examples
redisearch

How to do a redisearch search for items that have @field with a - in it?


I have an redisearch index with products where the fields does contain special characters like "-". I'm keep hititng the wall with trying to do a search for products where the category field is "Multiroom-høttaler".

Here is a sample entry straight from redis-cli:

 1) shortDescription
 2) "\"Urbanears Stammen multiroom-h\xc3\xb8yttaler leverer stor, velbalansert lyd i et design som harmonerer med interi\xc3\xb8ret til ethvert hjem.\""
 3) brand
 4) "\"Urbanears\""
 5) title
 6) "\"Urbanears Stammen multiroom-h\xc3\xb8yttaler (bl\xc3\xa5)\""
 7) articleNumber
 8) "\"STAMMENBU\""
 9) category
10) "\"Multiroom-h\xc3\xb8yttaler\""

I have tried the following, including running ft.explain on all of them from cli and rdm with no luck in getting any hits. I also want it to be an exact match.

So far they all return 0 hits.

ft.search no @category:Multiroom-høyttaler
ft.search no @category:Multiroom\-høyttaler
ft.search no @category:Multiroom\\-høyttaler
ft.search no @category:\"Multiroom-høyttaler\"
ft.search no @category:\"Multiroom\\-høyttaler\"
ft.search no @category:\\"Multiroom\-høyttaler\\""
ft.search no @category:"\\"Multiroom\\-høyttaler\\""

I would expect to get all the products with the category Multiroom-høyttaler.


Solution

  • Your problem is that you also need to index the field with the - escaped.