如何使用SQL CONTAINS查询Cosmos DB图 [英] How to Query Cosmos DB graph by use of SQL CONTAINS
本文介绍了如何使用SQL CONTAINS查询Cosmos DB图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个Cosmo DB图,我想在其中使用与Cosmos DB中匹配的字符串CONTAINS来访问表达式中的名称"字段. CONTAINS与匹配CONATINS一样在1级起作用
I have a Cosmo DB graph where I would like to access the 'name' field in an expression using the string matching CONTAINS in Cosmos DB. CONTAINS works at 1 level as in matching CONATINS
-
SELECT s.label, s.name FROM s WHERE CONTAINS(LOWER(s.name._value), "cara") AND s.label = "site"
我也尝试过使用UDF函数
I also tried with a UDF function
-
SELECT s.label, s.name FROM s WHERE(s.label = 'site' AND udf.strContains(s.name._value, '/cara/i'))
我在Cosmos DB中没有发现任何匹配或语法错误,即使在该示例中至少应该是一条记录.有人暗示吗?预先感谢
I don't get any hits or syntax errors from Cosmos DB even that should be at least one record in this example. Does anyone have a hint? Thanks in advance
[
{
"label": "site",
"name": [
{
"_value": "0315817 Caracol",
"id": "2e2f000d-2e0a-435a-b472-75d257236558"
}
]
},
{
"label": "site",
"name": [
{
"_value": "0315861 New Times",
"id": "48497172-1734-43d0-9866-51faf9f603ed"
}
]
}
]
推荐答案
我注意到name
属性是一个数组而不是对象.因此,您需要在sql中使用join
.
I noticed that the name
property is an array not an object.So, you need to use join
in sql.
SELECT s.label, s.name , name._value FROM s
join name in s.name
where CONTAINS(LOWER(name._value), "cara") AND s.label = "site"
输出:
希望它对您有帮助.
这篇关于如何使用SQL CONTAINS查询Cosmos DB图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文