How can we improve Azure Cosmos DB?

Add support for "Search text" ($text Operator)

Support for "Mongo Search Text" ( Example of use:

db.stores.find( { $text: { $search: "java coffee shop" } } )

80 votes
Sign in
Sign in with: oidc
Signed in as (Sign out)
You have left! (?) (thinking…)
Alexandre Ribeiro shared this idea  ·   ·  Flag idea as inappropriate…  ·  Admin →


Sign in
Sign in with: oidc
Signed in as (Sign out)
  • Anonymous commented  ·   ·  Flag as inappropriate

    Using azure search as a "solution" is awful, it's clunky and requires workarounds for something that is built into Mongo. Now not only do you have to pay for two services Cosmos as well as Search you now have a more brittle system due to more components. If you're claiming a compliant API this is a pretty poor solution.

  • PGR commented  ·   ·  Flag as inappropriate

    The $regex operator does not work with Full text indexes. Azure Search is not available in some regions like China so are there other options to make full text index search in CosmosDB for MongoDB

  • AdminAzure Cosmos DB Team (Product Manager, Microsoft Azure) commented  ·   ·  Flag as inappropriate

    Pretty much all of $text functionality (and more) has been implemented in Azure Search and we're happy to let you know that it now supports for MongoDB API collections (in private preview). Working with MongoDB collections is very similar to working with SQL Cosmos DB collections as described in

    To create a MongoDB datasource, POST an HTTP request as shown below:

    POST https://[service name]
    Content-Type: application/json
    api-key: [Search service admin key]

    "name": "mymongodbdatasource",
    "type": "documentdb",
    "credentials": {
    "connectionString": "AccountEndpoint=https://<Your Cosmos DB account name>;AccountKey=<Your Cosmos DB account key>;Database=<Your database>;ApiKind=MongoDb"
    "container": { "name": "<Your collection>", "query": null },
    "dataChangeDetectionPolicy": {
    "@odata.type": "#Microsoft.Azure.Search.HighWaterMarkChangeDetectionPolicy",
    "highWaterMarkColumnName": "_ts"


    1. Use `documentdb` as the data source type.
    2. Do not use a MongoDB connection string that you would use in your MongoDB application. Instead, construct the connection string as shown above. Make sure to add **ApiKind=MongoDb** to the connection string.

    Once you've created the data source, follow the steps in to create a search index, create an indexer, and monitor the indexer execution.

    ## Known issues and limitations

    1. Only the REST API is supported. For now, you cannot create or edit MongdoDB data sources using Azure Portal or Azure Search .NET SDK. However, you **can** monitor execution history of MongoDB indexers in the portal.

    2. Custom queries are not supported: `container.query` parameter must be set to null or omitted. If you need to use a custom query, please let us know at the emails below.

    If you encounter any issues, please contact

  • AdminAzure Cosmos DB Team (Product Manager, Microsoft Azure) commented  ·   ·  Flag as inappropriate

    Currently, simple text search is provided through $regex operator. More comprehensive text search is coming shortly through Azure Search that will be able to index MongoDB API collections as well:

Feedback and Knowledge Base