Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does DocumentDB support the LIKE keyword in queries?

Can we use the LIKE keyword to filter out records as we use it in T-SQL?

like image 450
Joker_37 Avatar asked Apr 16 '16 10:04

Joker_37


People also ask

How do you use like in Cosmos db query?

UPDATE : You can now use the LIKE keyword to do text searches in Azure Cosmos DB SQL (core) API! (i) Currently Azure Cosmosdb supports the CONTAINS , STARTSWITH , and ENDSWITH built-in functions which are equivalent to LIKE. The keyword for LIKE in Cosmosdb is Contains .

Is Cosmos DB a DocumentDB?

Azure Cosmos DB is the next big leap in globally distributed, at scale, cloud databases. As a DocumentDB customer, you now have access to the new breakthrough system and capabilities offered by Azure Cosmos DB.

Is DocumentDB compatible with MongoDB?

Amazon DocumentDB (with MongoDB compatibility) is a fast, scalable, highly-available, and fully managed document database service that supports MongoDB workloads. Amazon DocumentDB is compatible with the MongoDB 3.6 and 4.0 APIs. This section lists the supported functionality.


1 Answers

The keyword for LIKE is CONTAINS. If you had a document with a firstName property and you wanted to filter on the name 'bob' you would use it in a query this way:

"SELECT * FROM c WHERE CONTAINS(c.firstName, 'bob')"

Or if you were using Linq and assuming you had a class Person with a FirstName property the same query would work this way:

 var dbClient = GetClient();  var docs = dbClient.CreateDocumentQuery<Person>(Collection)                     .Where(p => p.FirstName.Contains("bob"); 
like image 100
cnaegle Avatar answered Nov 08 '22 12:11

cnaegle