FTS Search UUID not working

FTS queries don’t work on UUID values

example code

sq = couchbase.SearchQuery.regexp('76ec7e52-3d36-47d2-8550-7d674cb5ef75').field('docId');
sq = couchbase.SearchQuery.term('76ec7e52-3d36-47d2-8550-7d674cb5ef75').field('docId');

For regexp if I use just 7d674cb5ef75 for example (or any other sub-part of the string) it works fine.
For term if I run it on a generated hash instead of UUID it works fine.

Anything with a - doesn’t work on the couchbase documentation doesn’t provide any solution

@Gabriel_P You can do this by setting the analyzer for the query to “keyword”. You can explicitly set this by using a match query -or- by updating the default_analyzer in the index definition which will be used for other queries.

If the default_analyzer set for the field is “standard” (default setting), “-” is a stop word/character, so the tokens stored would be {“76ec7e52”, “3d36”, “47d2”, “8550”, “7d674cb5ef75”} for 76ec7e52-3d36-47d2-8550-7d674cb5ef75.

Note that it is important that your query and field mapping’s analyzer match for the search to match the indexed tokens.

Thank you for your reply.

What happens if you have multiple Search Query functions and only that one is a keyword?

sq = couchbase.SearchQuery.term('76ec7e52-3d36-47d2-8550-7d674cb5ef75').field('docId');
sq.term('contacts').field('docType');
sq.match('firstName').field('firstName');

docType and firstName fields work fine with the default analyzer.

Cool, so you can do that in 2 steps …

  1. While you’re defining the index, set the analyzer for the field “docId” to “keyword”
  2. Replace you’re search query: couchbase.SearchQuery.term(‘76ec7e52-3d36-47d2-8550-7d674cb5ef75’).field(‘docId’) with couchbase.SearchQuery.match(‘76ec7e52-3d36-47d2-8550-7d674cb5ef75’).field(‘docId’).

The match query allows you to set an analyzer explicitly, and should you not do that it will go ahead and pick up the analyzer that has been assigned for the field within the index definition.