Begins with and ends with searches

Hello!
I am looking into full-text search functionality. For example: a text like Sky is beautiful today and sun is out.
My search requirement is : Find text that “Begins with Sky and ends with out”.
What would be the best way to write a search query to achieve this?

Thanks,
Supriya

Hi @Supriya_Bansal,

I suggest you look into Atlas Search service:

https://docs.atlas.mongodb.com/reference/atlas-search/regex/

In particular the regex operator queries sounds like a suitable one.

Thanks
Pavel

Thanks @Pavel_Duchovny. I was thinking of regex too…just wanted to check if there is anything else besides that option.

specifying the order, regex in Atlas Search is the best option. However, you can test some of the functionality you described using the autocomplete operator as well.

1 Like