Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Syntax for Azure Cosmos DB CONTAINS

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?

like image 263
amy8374 Avatar asked Mar 01 '17 20:03

amy8374


People also ask

What language is Cosmos DB written in?

NET, Node. js (JavaScript), Java and Python.

How do I query data in Azure Cosmos DB?

In the Azure Cosmos DB blade, locate and select the Data Explorer link on the left side of the blade. In the Data Explorer section, expand the NutritionDatabase database node and then expand the FoodCollection container node. Within the FoodCollection node, select the Items link. View the items within the container.

How do you write to Cosmos DB from Azure function?

In the Azure portal, navigate to and select the function app you created previously. Select Functions, and then select the HttpTrigger function. Select Integration and + Add output. Name of the binding type to select to create the output binding to Azure Cosmos DB.

What are items in Cosmos DB?

Azure Cosmos DB items Depending on which API you use, data can represent either an item in a container, a document in a collection, a row in a table, or a node or edge in a graph. The following table shows the mapping of API-specific entities to an Azure Cosmos item: Cosmos entity. SQL API. Cassandra API.


1 Answers

Try this:

SELECT VALUE c FROM c JOIN s in c.soldItems WHERE CONTAINS(s.item, "BEER") 
like image 151
Larry Maccherone Avatar answered Sep 20 '22 13:09

Larry Maccherone