FT Search not searching text having some special character

I have a created a HMSET from Java using jedis. All looks well when I check it from redisInsight.
My requirement is that I want to do search on an ID which looks like
FT.SEARCH "idx:segmPreformatted textent" c9459fef-e092-457b-a278-497ffd86efc1
This never get me result may be because of tokenisation.
I even tried escaping “-” with “\-” (from java client) which stores data as “393767bb-50b7-4cab-a36f-b911f557f9a7”
Now I have tried searching for it with
FT.SEARCH "idx:segment" c9459fef-e092-457b-a278-497ffd86efc1
or
FT.SEARCH "idx:segment" "393767bb\-50b7\-4cab\-a36f\-b911f557f9a7"
I am still not able to find it.
Please help.

P.S instead of keeping it a TEXT, I changed it to a TAG and now it gives me an Syntax error while I am querying
FT.SEARCH "idx:segment" "@tags:{f14a474c4-c816-43ad-b0c4-cd432175fb47}"

Hey @vyj7
As you already figure out you need to escape the ‘-’ but you also need to declare the fields as TAG field so it will not be tokenized on indexing time

you need to escape the ‘-’ on query time.

1 Like

It worked. But I am still confused.
For Tags, I thought since it wont be tokenising the string, so it will ignore the special Char.

Yes, but only on index time, on query time (because of parsing internals) currently you still need to escape it. We are planing fix it in the future and allow no escaping queries on TAGS fields.

oh. Understood. Thanks a lot :grinning:

1 Like

Do I need to escape all the special Characters whenever they come during query?

Yes (unless you want your query to be tokenized …)

Thanks :slight_smile:

1 Like