Thanks for the response. Assuming “ids” is a collection of strings, this is how I built my filter in C#:
Builders<[MY CLASS]>.Filter.Or(ids.Select(id => filterBuilder.Eq(r => r.Id, id)))
When I run ToString on my IFindFluent, I get what I believe to be the final Mongo query:
find({ \"$or\" : [{ \"_id\" : ObjectId(\"123\") }, { \"_id\" : ObjectId(\"456\") }, { \"_id\" : ObjectId(\"789\") }] }).sort({ \"_id\" : 1 })
(But with real object IDs and a whole lot more of them.)
I then call ToAsyncEnumerable and try to iterate the enumerable:
var enumerable = _collection.Find(...).ToAsyncEnumerable(cancellationToken);
await foreach (T item in enumerable.WithCancellation(cancellationToken).ConfigureAwait(false))
{
// do work...
}
Everything works when I use 500 IDs, but 1000 IDs results in this exception being throw (simplified IDs like before):
{"Command find failed: Error=2, Details='Response status code does not indicate success: BadRequest (400); Substatus: 0; ActivityId: 86a080ef-3cd2-426c-bdbc-a674979c674a; Reason: (Response status code does not indicate success: BadRequest (400); Substatus: 0; ActivityId: 86a080ef-3cd2-426c-bdbc-a674979c674a; Reason: (Response status code does not indicate success: BadRequest (400); Substatus: 0; ActivityId: 86a080ef-3cd2-426c-bdbc-a674979c674a; Reason: (Message: errors \u0005\u0001 severity Error location \u0010 start \u0004 end \u0004 code SC1030 message~ Tt\u0019\u0014 yPz\u000e ߠ \rg \u001b$. < .\u0010\u0015 sP = u \a e\u0010 \r\n ey\u001eD. < ] d\u0010 -\a m8 O x < nP \r ˠx ,ϻ@÷{ & \u001c^ g\u0010\u001d]\u0006 ey\u001e v ߠv MO eм\u001df rP ^ s\u0016 -\a m8;mΧ g\u0010\u001d]\u0006 m8 \a pyy>O .\r\nActivityId: 86a080ef-3cd2-426c-bdbc-a674979c674a, Request URI: /apps/DocDbApp/services/DocDbServer10/partitions/a4cb4956-38c8-11e6-8106-8cdcd42c33be/replicas/1p/
, RequestStats: Microsoft.Azure.Cosmos.Tracing.TraceData.ClientSideRequestStatisticsTraceDatum, SDK: Windows/10.0.22000 cosmos-netstandard-sdk/3.18.0);););."}
Code: 2
CodeName: "BadValue"
Command: {{ "find" : "items", "filter" : { "$or" : [{ "_id" : ObjectId("123") }, { "_id" : ObjectId("456") }, { "_id" : ObjectId("789") }] }, "sort" : { "_id" : 1 }, "skip" : 0, "limit" : 500 }}
ConnectionId: {{ ServerId : { ClusterId : 1, EndPoint : "Unspecified/localhost:10255" }, LocalValue : 3, ServerValue : "663943947" }}
Data: {System.Collections.ListDictionaryInternal}
ErrorLabels: Count = 0
ErrorMessage: "Error=2, Details='Response status code does not indicate success: BadRequest (400); Substatus: 0; ActivityId: 86a080ef-3cd2-426c-bdbc-a674979c674a; Reason: (Response status code does not indicate success: BadRequest (400); Substatus: 0; ActivityId: 86a080ef-3cd2-426c-bdbc-a674979c674a; Reason: (Response status code does not indicate success: BadRequest (400); Substatus: 0; ActivityId: 86a080ef-3cd2-426c-bdbc-a674979c674a; Reason: (Message: errors \u0005\u0001 severity Error location \u0010 start \u0004 end \u0004 code SC1030 message~ Tt\u0019\u0014 yPz\u000e ߠ \rg \u001b$. < .\u0010\u0015 sP = u \a e\u0010 \r\n ey\u001eD. < ] d\u0010 -\a m8 O x < nP \r ˠx ,ϻ@÷{ & \u001c^ g\u0010\u001d]\u0006 ey\u001e v ߠv MO eм\u001df rP ^ s\u0016 -\a m8;mΧ g\u0010\u001d]\u0006 m8 \a pyy>O .\r\nActivityId: 86a080ef-3cd2-426c-bdbc-a674979c674a, Request URI: /apps/DocDbApp/services/DocDbServer10/partitions/a4cb4956-38c8-11e6-8106-8cdcd42c33be/replicas/1p/, Re
questStats: Microsoft.Azure.Cosmos.Tracing.TraceData.ClientSideRequestStatisticsTraceDatum, SDK: Windows/10.0.22000 cosmos-netstandard-sdk/3.18.0);););"
HResult: -2146233088
HelpLink: null
InnerException: null
Message: "Command find failed: Error=2, Details='Response status code does not indicate success: BadRequest (400); Substatus: 0; ActivityId: 86a080ef-3cd2-426c-bdbc-a674979c674a; Reason: (Response status code does not indicate success: BadRequest (400); Substatus: 0; ActivityId: 86a080ef-3cd2-426c-bdbc-a674979c674a; Reason: (Response status code does not indicate success: BadRequest (400); Substatus: 0; ActivityId: 86a080ef-3cd2-426c-bdbc-a674979c674a; Reason: (Message: errors \u0005\u0001 severity Error location \u0010 start \u0004 end \u0004 code SC1030 message~ Tt\u0019\u0014 yPz\u000e ߠ \rg \u001b$. < .\u0010\u0015 sP = u \a e\u0010 \r\n ey\u001eD. < ] d\u0010 -\a m8 O x < nP \r ˠx ,ϻ@÷{ & \u001c^ g\u0010\u001d]\u0006 ey\u001e v ߠv MO eм\u001df rP ^ s\u0016 -\a m8;mΧ g\u0010\u001d]\u0006 m8 \a pyy>O .\r\nActivityId: 86a080ef-3cd2-426c-bdbc-a674979c674a, Request URI: /apps/DocDbApp/services/DocDbServer10/partitions/a4cb4956-38c8-11e6-8106-8cdcd42c33be/
replicas/1p/, RequestStats: Microsoft.Azure.Cosmos.Tracing.TraceData.ClientSideRequestStatisticsTraceDatum, SDK: Windows/10.0.22000 cosmos-netstandard-sdk/3.18.0);););."
Result: {{ "ok" : 0.0, "errmsg" : "Error=2, Details='Response status code does not indicate success: BadRequest (400); Substatus: 0; ActivityId: 86a080ef-3cd2-426c-bdbc-a674979c674a; Reason: (Response status code does not indicate success: BadRequest (400); Substatus: 0; ActivityId: 86a080ef-3cd2-426c-bdbc-a674979c674a; Reason: (Response status code does not indicate success: BadRequest (400); Substatus: 0; ActivityId: 86a080ef-3cd2-426c-bdbc-a674979c674a; Reason: (Message: errors \u0005\u0001 severity Error location \u0010 start \u0004 end \u0004 code SC1030 message~ Tt\u0019\u0014 yPz\u000e ߠ \rg \u001b$. < .\u0010\u0015 sP = u \u0007 e\u0010 \r\n ey\u001eD. < ] d\u0010 -\u0007 m8 O x < nP \r \u02e0x ,ϻ@÷{ & \u001c^ g\u0010\u001d]\u0006 ey\u001e v ߠv MO eм\u001df rP ^ s\u0016 -\u0007 m8;mΧ g\u0010\u001d]\u0006 m8 \u0007 pyy>O .\r\nActivityId: 86a080ef-3cd2-426c-bdbc-a674979c674a, Request URI: /apps/DocDbApp/services/DocDbServer10/partitions/a4cb4956-38c
8-11e6-8106-8cdcd42c33be/replicas/1p/, RequestStats: Microsoft.Azure.Cosmos.Tracing.TraceData.ClientSideRequestStatisticsTraceDatum, SDK: Windows/10.0.22000 cosmos-netstandard-sdk/3.18.0);););", "code" : 2, "codeName" : "BadValue" }}
Source: "MongoDB.Driver.Core"
StackTrace: " at MongoDB.Driver.Core.WireProtocol.CommandUsingCommandMessageWireProtocol`1.ProcessResponse(ConnectionId connectionId, CommandMessage responseMessage)\r\n at MongoDB.Driver.Core.WireProtocol.CommandUsingCommandMessageWireProtocol`1.<ExecuteAsync>d__20.MoveNext()\r\n at MongoDB.Driver.Core.Servers.Server.ServerChannel.<ExecuteProtocolAsync>d__20`1.MoveNext()\r\n at MongoDB.Driver.Core.Operations.RetryableReadOperationExecutor.<ExecuteAsync>d__3`1.MoveNext()\r\n at MongoDB.Driver.Core.Operations.ReadCommandOperation`1.<ExecuteAsync>d__8.MoveNext()\r\n at MongoDB.Driver.Core.Operations.FindOperation`1.<ExecuteAsync>d__129.MoveNext()\r\n at MongoDB.Driver.Core.Operations.FindOperation`1.<ExecuteAsync>d__128.MoveNext()\r\n at MongoDB.Driver.OperationExecutor.<ExecuteReadOperationAsync>d__3`1.MoveNext()\r\n at MongoDB.Driver.MongoCollectionImpl`1.<ExecuteReadOperationAsync>d__99`1.MoveNext()\r\n at MongoDB.Driver.MongoCollectionImpl`1.<UsingImplicitSessionAsync>d__107`1.MoveNex
t()\r\n at DataCollection.Data.Extensions.IAsyncCursorSourceExtensions.<ToAsyncEnumerable>d__0`1.MoveNext() in C:\\Source\\sawtooth\\DataCollection\\src\\DataCollection.Data\\Extensions\\IAsyncCursorSourceExtensions.cs:line 12\r\n at DataCollection.Data.Extensions.IAsyncCursorSourceExtensions.<ToAsyncEnumerable>d__0`1.System.Threading.Tasks.Sources.IValueTaskSource<System.Boolean>.GetResult(Int16 token)\r\n at System.Threading.Tasks.ValueTask`1.get_Result()\r\n at System.Runtime.CompilerServices.ConfiguredValueTaskAwaitable`1.ConfiguredValueTaskAwaiter.GetResult()\r\n at DataCollection.Business.Helpers.GetRespondentsHelper.<ToListAsync>d__20`1.MoveNext() in C:\\Source\\sawtooth\\DataCollection\\src\\DataCollection.Business\\Helpers\\GetRespondentsHelper.cs:line 213\r\n at DataCollection.Business.Helpers.GetRespondentsHelper.<ToListAsync>d__20`1.MoveNext() in C:\\Source\\sawtooth\\DataCollection\\src\\DataCollection.Business\\Helpers\\GetRespondentsHelper.cs:line 213"
TargetSite: {TCommandResult ProcessResponse(MongoDB.Driver.Core.Connections.ConnectionId, MongoDB.Driver.Core.WireProtocol.Messages.CommandMessage)}
I assumed such a cryptic error message wouldn’t be of any help, but perhaps it means something to you.