Can we use the LIKE keyword to filter out records as we use it in T-SQL?
28
votes
1 Answers
42
votes
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");