Skip to Main Content

MongoByte MongoDB Logo

Welcome to the new MongoDB Feedback Portal!

{Improvement: "Your idea"}
We’ve upgraded our system to better capture and act on your feedback.
Your feedback is meaningful and helps us build better products.

Status Completed
Categories Atlas Search
Created by Guest
Created on Sep 24, 2020

Text Search with regex

It would be great if Text Search allows us to query with regular expressions. E.g. mycoll.find({ $text: { $search: "super%"} }) Thank you for considering my request.
  • Guest
    Feb 7, 2022
    I am not sure if in this way text index is used. Is it?
  • Guest
    Jan 28, 2022
    You can do text search with regex but it won't use the syntax you included above. You can read about the syntax here: https://docs.atlas.mongodb.com/atlas-search/regex/ Here is an example from the docs: db.movies.aggregate([ { "$search": { "regex": { "path": "title", "query": "(.*) Seattle" } } }, { $project: { "_id": 0, "title": 1 } } ])