Efficiently pattern matching

I have millions documents contains email field
How can I efficiently find email addresses that contains specific word? Pattern like ℅myWord%

You can follow this
https://dzone.com/articles/a-couchbase-index-technique-for-like-predicates-wi
Example 6 https://docs.couchbase.com/server/6.0/n1ql/n1ql-language-reference/tokenfun.html

Or you can use FTS index. cc @keshav_m

Tokens() gives you a simple way to create a standard index and query.

Using FTS is also an alternative depending on the stemming, fuzziness requirements you have.

Can you show me how can I do this with FTS??

You can check this for quick reference. https://blog.couchbase.com/searching-json-comparing-text-search-in-couchbase-and-mongodb/

@abhinav , Could you help here.

Hey @socketman2016, here’s one way you can do it …
Set up an FTS type mapping over your specific field (emailID) in this case.
I’d recommend using the Simple analyzer to start with …

An example …

emailID: abc.def@xyz.com
".", "@" are stop words with the simple analyzer
So, tokens generated with this analyzer would be: abc def xyz com
However, numbers won't be tokenized by this analyzer, i.e
tokens generated from abc.123@xyz.com would be: abc, xyz, com

You also would have the power to set up a custom analyzer that will generate tokens based on the rule set you define.
Here’s where you can test what tokens are generated for search terms while using different analyzers…
http://bleveanalysis.couchbase.com/analysis