0
votes

I am planning to migrate all my mongoDb database to azure cosmosDB. For the testing purposes I was trying to test all the queries by making azure cosmosDB with mongo API as the underlying datasource. I was able to execute all the queries by creating some custom indices (Single field / wildcard) in cosmosDB. But a particular query is failing. I couldn't find any noticable reason for the same. The query looks as follows (The query is somewhat too long with $in operator. I suspect that)

db.getCollection("rules").find({
   "$and":[
      {
         "$or":[
            {
               "subRules.ALL.leftOperand":"GROUP",
               "subRules.ALL.rightOperand":{
                  "$in":[
                       <4000+ values>
                  ]
               }
            },
            {
               "subRules.ALL.leftOperand":"MACHINE",
               "subRules.ALL.rightOperand":{
                  "$in":[
                       <4000+ values>
                  ]
               }
            }
         ]
      },
      {
         "ruleName":{
            "$regex":""
         }
      }
   ],
   "subRules.ANY.leftOperand":{
      "$ne":"COFFEE_AMOUNT"
   }
})

This exact query works well with mongo server. But when I run this in azure cosmos. I am getting the following error

error: {
    "ok" : 0,
    "errmsg" : "Error=2, Details='Response status code does not indicate success: BadRequest (400); Substatus: 0; ActivityId: 443df8b1-136f-4018-9d77-63b3442ab7f8; Reason: (Response status code does not indicate success: BadRequest (400); Substatus: 0; ActivityId: 443df8b1-136f-4018-9d77-63b3442ab7f8; Reason: (Response status code does not indicate success: BadRequest (400); Substatus: 0; ActivityId: 443df8b1-136f-4018-9d77-63b3442ab7f8; Reason: (Message: ��errors�ꠈseverity�Error�location�\u000e�start\u0000�end�5\u0002�code�SC3031�message~pTt\u00194�2A�zY�\u0007���r�\\&���2�\u001dƧ��6�]o��r��\f�6�E{�\rz���0�-���a:\u001a�.��t4�\u001c���av�=.�@Tt\u0019\u0014f���2\u0019�N��tPz\u000e��\\\r\nActivityId: 443df8b1-136f-4018-9d77-63b3442ab7f8, Request URI: /apps/27c904fe-36bc-4acd-b55d-2c8494082ce7/services/c88f5dcc-2b90-4935-9281-38171d9dd72a/partitions/398285ee-29c1-4564-8e79-91c184ef65dd/replicas/132769491079094442s/, RequestStats: Microsoft.Azure.Cosmos.Tracing.TraceData.ClientSideRequestStatisticsTraceDatum, SDK: Windows/10.0.17763 cosmos-netstandard-sdk/3.18.0);););",
    "code" : 2,
    "codeName" : "BadValue"
}

I have tried creating wildcard index on the particular collection. Still it fails.

Nb : When the values in the array of $in operator is few the query executes successfully in cosmosDB as well!!

If anyone can shed some light to this issue it will be much appreciated. Thank you

I don't know particular reason, but cosmosDb API and mongo API are not 100% compatibledododo