如何在Azure Cosmos DB中深度搜索JSON?

编程入门 行业动态 更新时间:2024-10-20 00:35:47
本文介绍了如何在Azure Cosmos DB中深度搜索JSON?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我在Cosmos DB中存储了如下所示的JSON文件.我想搜索活动/消息中的文本.

I have JSON files like below stored in Cosmos DB. I want to search text in activities/message.

{ "id": "575858a7-f814-41fd-ae5a-6f38ba2da957", "name": "Test Name", "activities": [ { "message": "activity 1.1 message", "messageType": "type1" }, { "message": "activity 1.2 message", "messageType": "type2" } ] }

我发现我可以使用如下所示的搜索方式.

I find out that I can use search like below.

SELECT * FROM c WHERE CONTAINS(c.activities[0].message, "activity")

但是,这只能搜索活动数组中的第一条记录.如何搜索数组中的所有记录?谢谢.

But, this can only search the first record in the array of activities. How to search all records in the array? Thanks.

推荐答案

您需要在查询中应用联接,因此,数组将被视为规范化实体,然后可以应用过滤器.

You need to apply a join on your query, so then you array will be treated as a normalized entity and then you can apply the filter.

select c.id, a.message from c join a in c.activities where CONTAINS(a.message,"activity")

更多信息

更多推荐

如何在Azure Cosmos DB中深度搜索JSON?

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

发布评论

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

>www.elefans.com

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