搜索

基本搜索

qianmoQqianmoQ· 更新于 2026-09-27· 阅读 7 分钟· 0 次阅读

登录后可跨设备保存划线和私人笔记登录

基本搜索

基本搜索允许你使用实体的类型名称(typename)进行查询,并支持关联的分类/标签,同时支持按实体属性以及分类/标签属性进行过滤。

整个查询结构可以使用以下 JSON 结构来表示(称为 SearchParameters):

{
  "typeName":               "hive_column",
  "excludeDeletedEntities": true,
  "classification":         "PII",
  "query":                  "",
  "offset":                 0,
  "limit":                  25,
  "entityFilters":          {  },
  "tagFilters":             { },
  "attributes":             [ "table", "qualifiedName"]
}

字段说明

typeName:               the type of entity to look for
excludeDeletedEntities: should the search exclude deleted entities? (default: true)
classification:         only include entities with given classification
query:                  any free text occurrence that the entity should have (generic/wildcard queries might be slow)
offset:                 starting offset of the result set (useful for pagination)
limit:                  max number of results to fetch
entityFilters:          entity attribute filter(s)
tagFilters:             classification attribute filter(s)
attributes:             attributes to include in the search result

可以基于多个属性进行过滤,并使用 AND/OR 条件进行组合。

过滤示例(针对 hive_table 的属性)

  • 单个属性
   {
     "typeName":               "hive_table",
     "excludeDeletedEntities": true,
     "offset":                 0,
     "limit":                  25,
     "entityFilters": {
        "attributeName":  "name",
        "operator":       "contains",
        "attributeValue": "customers"
     },
     "attributes": [ "db", "qualifiedName" ]
   }

  • 多属性(使用 OR)
   {
     "typeName":               "hive_table",
     "excludeDeletedEntities": true,
     "offset":                 0,
     "limit":                  25,
     "entityFilters": {
        "condition": "OR",
        "criterion": [
           {
              "attributeName":  "name",
              "operator":       "contains",
              "attributeValue": "customers"
           },
           {
              "attributeName":  "name",
              "operator":       "contains",
              "attributeValue": "provider"
           }
        ]
     },
     "attributes": [ "db", "qualifiedName" ]
   }

  • 带 AND 条件的多属性
   {
     "typeName":               "hive_table",
     "excludeDeletedEntities": true,
     "offset":                 0,
     "limit":                  25,
     "entityFilters": {
        "condition": "AND",
        "criterion": [
           {
              "attributeName":  "name",
              "operator":       "contains",
              "attributeValue": "customers"
           },
           {
              "attributeName":  "owner",
              "operator":       "eq",
              "attributeValue": "hive"
           }
        ]
     },
     "attributes": [ "db", "qualifiedName" ]
  }

筛选支持的运算符

  • LT(符号:<、lt)适用于数值、日期属性
  • GT(符号:>、gt)适用于数值、日期属性
  • LTE(符号:<=、lte)适用于数值、日期属性
  • GATE(符号:>=、gte)适用于数值、日期属性
  • EQ(符号:eq、=)适用于数值、日期、字符串属性
  • NEQ(符号:neq、!=)适用于数值、日期、字符串属性
  • LIKE(符号:like、LIKE)适用于字符串属性
  • STARTS_WITH(符号:startsWith、STARTSWITH)适用于字符串属性
  • ENDS_WITH(符号:endsWith、ENDSWITH)适用于字符串属性
  • CONTAINS(符号:contains、CONTAINS)适用于字符串属性

CURL 示例

curl -sivk -g
    -u <user>:<password>
    -X POST
    -d '{
            "typeName":               "hive_table",
            "excludeDeletedEntities": true,
            "classification":         "",
            "query":                  "",
            "offset":                 0,
            "limit":                  50,
            "entityFilters": {
               "condition": "AND",
               "criterion": [
                  {
                     "attributeName":  "name",
                     "operator":       "contains",
                     "attributeValue": "customers"
                  },
                  {
                     "attributeName":  "owner",
                     "operator":       "eq",
                     "attributeValue": "hive"
                  }
               ]
            },
            "attributes": [ "db", "qualifiedName" ]
          }'
    <protocol>://<atlas_host>:<atlas_port>/api/atlas/v2/search/basic

评论

登录后参与评论

正在加载评论…