'MongoDB "IN" filter Issue

I am trying to query mongodb collection using Aggregate and IN Filter, like this

var filters = Builders<Model>.Filter.In(x => (Guid)x.Id, listOfIds);

recordsfromCollection = await _collection.Find(filters).Project(new BsonDocument
{
    {
        "Id", "$Id"
    },
    {
        "Name", "$Name"
    },
    {
        "Email", "$Email"
    }
}).ToListAsync();

The above code works when the list has around 8000 records.

and throws the below error if the list of ids is more than 9000

Command find failed: Error=2, Details='Response status code does not indicate success: BadRequest (400); Substatus: 0; ActivityId: e93d4e1d-c400-4124-9f96-b70c99a16ed4; Reason: (Response status code does not indicate success: BadRequest (400); Substatus: 0; ActivityId: e93d4e1d-c400-4124-9f96-b70c99a16ed4; Reason: (Response status code does not indicate success: BadRequest (400); Substatus: 0; ActivityId: e93d4e1d-c400-4124-9f96-b70c99a16ed4; Reason: (Message: ��errors�ꀈseverity�Error�location� �start

any help on this?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source