Syntax for Azure Cosmos DB CONTAINS

28,960

Try this:

SELECT VALUE c FROM c JOIN s in c.soldItems WHERE CONTAINS(s.item, "BEER")
Share:
28,960
amy8374
Author by

amy8374

Updated on April 14, 2020

Comments

  • amy8374
    amy8374 about 4 years

    I have the following JSON Store on Azure Cosmos DB.

    {
      "id": "4",
      "total": 10.46,
      "tax": 0.55,
      "soldItems": [
        {
          "item": "CHEESE NIPS 004400001300 F 1.97 D",
          "price": 1.97
        },
        {
          "item": "ROOT BEER 10.46",
          "price": 10.46
        }
        ]
    }
    

    and I am getting no results from this query:

    SELECT * from c where CONTAINS(c.soldItems.item, "BEER")
    

    What would be the correct syntax to check for a string in an JSON object value?