通过REST API的Cosmos DB IN子句 [英] Cosmos DB IN Clause thru REST API
问题描述
我无法使用IN
子句为Azure Cosmos文档DB制定搜索查询
I am unable to formulate search query using IN
clause for Azure Cosmos document DB
查询
{
"query": "SELECT * FROM LOADS l WHERE l.schedulingSystem in (@schedulingSystem)",
"parameters": [
{
"name": "@schedulingSystem",
"value": "A,B"
}
]
}
我也尝试过在单引号"value": "'A','B'"
中提供值,但
不工作.我正在使用'x-ms-version', '2018-12-31'
标头进行查询
I have tried providing values in single quotes "value": "'A','B'"
as well but
did not work. I am using 'x-ms-version', '2018-12-31'
header for the query
没有错误响应,但是得到空白响应(此搜索条件的数据确实存在).
There is no error response but getting blank response (data do exist for this search criteria).
非常感谢任何帮助或指针.
Any help or pointers are really appreciated.
推荐答案
If you use a parameterized IN list with sqlQuerySpec, then it will be considered as a single value when the parameter is expanded.
请使用便捷的方式来编写查询,方法是使用 ARRAY_CONTAINS 代替,并将项目列表作为单个参数传递.请按以下方式调整您的查询:
Please use convenient way to write your query is to use ARRAY_CONTAINS instead and pass the list of items as a single parameter. Please adjust your query like this:
SELECT * FROM LOADS l WHERE ARRAY_CONTAINS(@schedulingSystem, l.schedulingSystem,false)
"parameters": [
{
"name": "@schedulingSystem",
"value": "['A','B']"
}
]
类似的问题供您参考:
1. https://github.com/Azure/azure -cosmos-dotnet-v2/issues/614
2.在Azure文档数据库(CosmosDB中) ).Net SDK
这篇关于通过REST API的Cosmos DB IN子句的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!