eatinasandwich
eatinasandwich

Reputation: 636

Unable to query cosmos mongodb to match array element

I'm trying match by array element while querying a mongodb in cosmos.

On my local mongodb I've been able to run something like db.broker.find({ matches: /^broker1$/i }) and can get back something like this

{
    "_id" : ObjectId("59ee148ee0f53d0d78e3d202"),
    "name" : "Broker name",
    "matches" : [ 
        "Broker1", 
        "Broker1 inc"
    ]
}

But when trying to do this with the azure db it returns no results. I did notice that the azure db is running on version 3.2 and locally I have 3.4 but the docs seem to be about the same for this kind of query. https://docs.mongodb.com/v3.2/tutorial/query-documents/#match-an-array-element

Is this a bug with Azure or do I need to be querying for array elements a different way?

Upvotes: 0

Views: 366

Answers (1)

alekseys
alekseys

Reputation: 321

This doesn't depend on 3.2/3.4 feature support as you pointed out it was available in MongoDB for awhile. Regex are currently supported by Cosmos DB but not over arrays as in this case.

Upvotes: 1

Related Questions