Text Index for Substring of a Field?

I am currently working as an Intern , and i am assigned a task to increase the speed of the Query, which is in the search bar.That is substring of an email should be queried accordingly.Can I use text indexes for email and make it work?

Hi @Zephaniah_N_A - welcome to the MongoDB Community Forum!

From what I understand in your question, you have a collection that stores emails as documents, and you’d like to add or speed up a search box that allows you to search for email documents that contain certain words. If that’s the case, then a text index and the $text operator should work reasonably well for you.

If your MongoDB cluster is hosted on MongoDB Atlas then you could use Atlas Search instead. It’s a little more complex to set up but it’s more powerful.

Mark

Hi @Mark_Smith , yeah the text sesrches are working fine for some of the cases.I meant some of the cases because let us consider an email zeph with any domain, my expected behavious should be that if i type for ze the query should return zeph which isn’t the case when using text indexes instead what i found out is it is using delimiters like .!-,. to split the token which is not the ideal behavious for my problem

Just to clarify, you’re searching for an email address, not an email body?

Yes, the email address in the sense it is stored as a string right.