搜索
关系搜索
登录后可跨设备保存划线和私人笔记登录
关系搜索
Apache Atlas 是一个元数据治理工具,其特性之一是能够针对已定义模型中的预定义实体进行搜索。
我们可以通过指定通用属性(例如"名称"、"限定名称"、"描述"等)、实体类型定义特有的属性(某些实体独有的属性,例如 hdfs_path 类型实体的"集群名称"),以及已应用的分类、实体子类型、已删除实体等参数来搜索这些实体。然而,这些结果仅返回满足搜索查询参数的实体。
关系与实体遵循类似的结构,用于描述两个实体端点之间的各种元数据。例如,假设在 hive_table 与 hive_db 之间的关系中,关系类型名称为 hive_table_db,它可以拥有自己的元数据,并作为属性添加到该模型中。
关系搜索允许你通过使用关系类型名称进行查询来获取两个实体模型之间的元数据,并且还支持基于关系属性进行过滤。
整个查询结构可以使用以下 JSON 结构(称为 RelationshipSearchParameters)来表示
{
"relationshipName": "hive_table_db",
"excludeDeletedEntities": true,
"offset": 0,
"limit": 25,
"relationshipFilters": { },
"sortBy": "table_name",
"sortOrder": ASCENDING,
"marker": "*"
}字段说明
relationshipName: the type of relationship to look for
excludeDeletedEntities: should the search exclude deleted entities? (default: true)
offset: starting offset of the result set (useful for pagination)
limit: max number of results to fetch
relationshipFilters: relationship attribute filter(s)
sortBy: attribute to which results are sorted by
sortOrder: sorting order of results
marker: add either offset or marker, value of marker for first page will be '*'
and value of nextMarker: in the response will be input of marker for subsequent pages基于属性的过滤可以在多个属性上使用 AND/OR 条件进行。
关系搜索的实际应用示例
以社交应用 Instagram 及其基本功能为例:
- 用户 创建 帖子
- 用户 对 帖子 做出反应
- 用户 创建 精选集
- 帖子 被添加到 精选集
下面的元数据模型展示了上述使用场景:

示例:假设用户 Ajay 将他庆祝排灯节的照片作为帖子上传,Divya、Rahul 等许多用户对他的帖子点了赞。
现在用户 Ajay 想要找出他的帖子获得的"点赞"反应数量。
在他的搜索中,他将关注 user_post 关系类型,并过滤出反应中包含"like"、且帖子名称中包含"Diwali"的记录。
过滤示例(针对 user_post 属性)
{
"relationshipName": "user_post",
"excludeDeletedEntities": true,
"offset": 0,
"limit": 25,
"relationshipFilters": {
"condition": "AND",
"criterion": [
{
"attributeName": "reaction",
"operator": "eq",
"attributeValue": "like"
},
{
"attributeName": "post_name",
"operator": "contains",
"attributeValue": "Diwali"
}
]
}
}筛选支持的运算符
与基础搜索支持的运算符相同
CURL 示例
curl -sivk -g
-u <user>:<password>
-X POST
-d '{
"relationshipName": "user_post",
"excludeDeletedEntities": true,
"offset": 0,
"limit": 25,
"relationshipFilters": {
"condition": "AND",
"criterion": [
{
"attributeName": "reaction",
"operator": "eq",
"attributeValue": "like"
},
{
"attributeName": "post_name",
"operator": "contains",
"attributeValue": "Diwali"
}
]
}
}'
<protocol>://<atlas_host>:<atlas_port>/api/atlas/v2/search/relations评论
登录后参与评论
正在加载评论…
KnowForge