MongoDB Atlas Search - slow count of matched documents

Hello, I have a collection with 11M records, which contains among other properties, a “Name” property with a client name:

{
    "Name" : "Teressa Bella"
}

I have created an Atlas Search index on the “Name” field with the following definition:

{
  "mappings": {
    "dynamic": false,
    "fields": {
      "Name": {
        "analyzer": "lucene.standard",
        "type": "string"
      }
    }
  }
}

My use case counting all the documents that match a certain term which I’m doing like so:

db.getCollection('recipients').aggregate([
  {
    $search: {
      "text": {
        "query": "Teressa",
        "path": "Name"
      }
    }
  },
  {
    $count: "total"
  }
])

The problem is that this query takes about 40s to complete on an M30 Atlas cluster (sometimes 10s or 20s if entirely fetched from memory, I presume).
Is this within the expected execution time for matching a term on 11M documents?
I would appreciate any suggestions on how i can optimize this kind of query.

I would try to project just the Name field. Since it is part of the index it is likely that the documents do no need be read from permanent storage.

This being said, if your use-case for using the Atlas Search is as simple as this, a normal index on the Name field might be a better fit.

Thanks for the tip, unfortunately it didn’t make a difference, probably because I’m only performing a count on the records.
My real use case will actually include more complex operations, like partial text searches. However, as I performed this simple test, i found the performance to be worse than I was expecting, so I was looking to know if there’s something I’m missing.

I got same problem !

But i have 500k documents and M40.

For same search as you, searching time was between 40s-50s…

Any help from Mongo Employee ?

@Jonathan_Gautier we should set up some time to chat. I want to help you and feel your pain.

Same with you @Pedro_Cristina. I’m the new Product Manager on Atlas Search and I want to make this better for you both.

@Marcus

Hi how can we help you to fix this issue ?

I have try to change my cluster tier from m30 to m50 but no change for search delay.
Guys from developper support said i need to change my cluster tier because m30 was overload but with m50 i got same result and it was not overload when my query was running.