Azure Cosmos DB Graph通配符搜索

编程入门 行业动态 更新时间:2024-10-19 12:34:58
本文介绍了Azure Cosmos DB Graph通配符搜索的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

是否可以在Azure Cosmos Graph DB中使用包含来搜索Vertex属性?

Is it possible to search Vertex properties with a contains in Azure Cosmos Graph DB?

例如,我想查找姓名中有'Jr'的所有人?

For example, I would like to find all persons which have 'Jr' in their name?

g.V().hasLabel('person').has('name',within('Jr')).values('name')

似乎像 within('')函数一样,仅过滤与'Jr'完全相等的值.我正在寻找一个包含.理想情况下,不区分大小写.

Seems like the within('') function only filters values that are exactly equal to 'Jr'. I am looking for a contains. Ideally case insensitive.

推荐答案

CosmosDB目前没有任何文本匹配功能.但是,我能够通过使用使用Javascript match()函数的UDF(用户定义函数)来实现通配符搜索功能:

None of the text matching functions are available for CosmosDB at this time. However, I was able to implement a wildcard search functionality by using a UDF (User Defined Function) which uses the Javascript match() function:

function userDefinedFunction(input, pattern) { return input.match(pattern) !== null; };

然后,您必须将查询编写为SQL并使用您定义的UDF(以下示例假定您调用了"REGEX"函数

Then you'd have to write your query as SQL and use the UDF that you defined (the example below assumes you called you function 'REGEX'

SELECT * FROM c where(udf.REGEX(c.name[0]._value, '.*Jr.*') and c.label='person')

性能将远非理想,因此您需要根据延迟和成本方面的观点来确定解决方案是否可以接受.

The performance will be far from ideal so you need to decide if the solution is acceptable or not based on your latency and cost perspectives.

更多推荐

Azure Cosmos DB Graph通配符搜索

本文发布于:2023-11-17 02:25:19,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1608471.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:通配符   Cosmos   Azure   Graph   DB

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!