Escaping characters in Full Text Search using the Node.js SDK

My search term looks like this:

tenant::location::d13c8a1c-ce8c-4bff-87f2-8bc2d2015f4e

I am using it in the following Node.js Couchbase SDK like this:

SearchQuery.match(tenant::location::d13c8a1c-ce8c-4bff-87f2-8bc2d2015f4e)

I need to escape the colon and dash. I have tried all of these examples:

SearchQuery.match(tenant\:\:location\:\:d13c8a1c\-ce8c\-4bff\-87f2\-8bc2d2015f4e)
SearchQuery.match(tenant\\:\\:location\\:\\:d13c8a1c\\-ce8c\\-4bff\\-87f2\\-8bc2d2015f4e)

No luck with these. I can get the search to work when I run it manually in the web admin site like this:

tenant\:\:location\:\:d13c8a1c\-ce8c\-4bff\-87f2\-8bc2d2015f4e

So how do I escape the colon and the dash when I am using the Node.js SDK for Full Text Search ?

Thanks,

Hi @koobani,

It is highly recommended to post any SDK related queries in the relevant SDK forums.
ref-https://forums.couchbase.com/c/node-js-sdk

Aside from that - not clear of your requirement details here.
If your search requirement is to exactly retrieve the documents where “tenant::location::d13c8a1c-ce8c-4bff-87f2-8bc2d2015f4e” occurs in $someField then,
you could index the $someField using a “keyword” analyzer and that would keep the whole field content intact without any tokenisation applied to the field contents in the inverted index.
This lets you search directly using the same format $someField:"tenant::location::d13c8a1c-ce8c-4bff-87f2-8bc2d2015f4e" without any character escaping.

Another thing to note is that - your character escaped searching pattern might be retrieving documents where any of the tokenised tokens of your search text appears and Not sure whether that is your requirement here.

Cheers!

@sreeks Thanks for the reply. Your answer was what we were looking for. We had the wrong analyzers on the fields we were storing keys in. Changing them to keyword analyzers did the trick. Thanks again and you have a great holidays.