Azure Cosmos Database Syntax CONTAINS

I have the following JSON Store in 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 get no results for this query:

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

What would be the correct syntax for checking a string in a JSON object value?

+16
source share
1 answer

Try the following:

 SELECT VALUE c FROM c JOIN s in c.soldItems WHERE CONTAINS(s.item, "BEER") 
+25
source

Source: https://habr.com/ru/post/1015384/


All Articles