Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-60955

$count stage is working too slow in mongoDb aggregation query

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • Labels:
      None
    • Server Triage
    • ALL

      Hello Sir/Madam,

       

      I have around 6 million products in my database and I am using atlas search to refine my search result. Everything is working fine, only $count stage is working slow. 

       
      totalItems = Product.aggregate([
                {
                  $search: {
                    autocomplete: {
                      query: searchQuery,
                      path: normal_path,
                      score: {
                        boost:

      {                     value: 2,                   }

      ,
                      },
                    },
                  },
                },
                {
                  $project: {
                    _id: 0,
                    score:

      {                 $meta: "searchScore",               }

      ,
                  },
                },
                {
                  $match:

      {               score: \{ $gt: 15 }

      ,
                  },
                },
               

      {             $limit: 100,           }

      ,
               

      {             $count: "count",           }

      ,
              ]);
       

            Assignee:
            backlog-server-triage [HELP ONLY] Backlog - Triage Team
            Reporter:
            tech@shopmebook.com Ankit Saini
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: