Hitting a limit of 50000 items

Here is my function

    if(filter.query.category)
    {
      strCategory = filter.query.category;
      strMustData["must"].push({"text": {"path": "category","query": strCategory}});
    }
    
     const filteredItems = await collection.aggregate([
      {
        $search: {
          index: "productIndexes",
          "compound": {
            "must": 
              strMustData.must
          }
        }
      },
        
      {
        $project: {
          "_id": 10,
          "title": 1,
          "object": 2,
          "price":3,
          "imgArray":6,
          "category": 7,
          score: { $meta: "searchScore" }
        }
      }
    ]).toArray();
      return filteredItems;

I pass a category ID and get the data and it returns the data but its only returns 50000 items

Capture

there is more than this in the data but i am only returning the 50000 is there a way to remove this limit

Hi @Aneurin_Jones and welcome to MongoDB community forums!!

As per my understanding, there is no limit on the results obtained by the query.
However, to understand further could you help me with some information which would help me reproduce the issue.

  1. The total number of documents in the collection.
  2. Can you confirm if the number of resultant document after search operation is more than 50000?

Regards
Aasawari

1 Like