Elasticsearch:注册域处理器 - registered domain processor

从完全限定域名 (fully qualified domain name - FQDN) 中提取注册域(也称为有效顶级域或 eTLD)、子域和顶级域。 使用 Mozilla 公共后缀列表中定义的注册域。

它有如下的选项:

名称 必须 默认 描述
field yes 包含源 FQDN 的字段。
target_field no <empty string> 包含提取的域组件的对象字段。 如果是<空字符串>,则处理器将组件添加到文档的根。
ignore_missing no true 如果为 true 并且缺少任何必填字段,则处理器会安静退出而不修改文档。
description no - 处理器的描述。 对于描述处理器或其配置的用途很有用。
if no - 有条件地执行处理器。 请参阅有条件地运行处理器
ignore_failure no false 忽略处理器的故障。 请参阅处理管道故障
on_failure no - 处理处理器的故障。 请参阅处理管道故障
tag no - 处理器的标识符。 对于调试和指标很有用。

示例

以下示例说明了注册域处理器的使用:

POST _ingest/pipeline/_simulate
{
  "pipeline": {
    "processors": [
      {
        "registered_domain": {
          "field": "fqdn",
          "target_field": "url"
        }
      }
    ]
  },
  "docs": [
    {
      "_source": {
        "fqdn": "www.example.ac.uk"
      }
    }
  ]
}

上面的命令返回:

{
  "docs": [
    {
      "doc": {
        "_index": "_index",
        "_id": "_id",
        "_version": "-3",
        "_source": {
          "fqdn": "www.example.ac.uk",
          "url": {
            "registered_domain": "example.ac.uk",
            "top_level_domain": "ac.uk",
            "domain": "www.example.ac.uk",
            "subdomain": "www"
          }
        },
        "_ingest": {
          "timestamp": "2023-07-05T01:27:04.720322Z"
        }
      }
    }
  ]
}

我们再来测试一下 www.elastic.co 的情况:

POST _ingest/pipeline/_simulate
{
  "pipeline": {
    "processors": [
      {
        "registered_domain": {
          "field": "fqdn",
          "target_field": "url"
        }
      }
    ]
  },
  "docs": [
    {
      "_source": {
        "fqdn": "www.elastic.co"
      }
    }
  ]
}

上面返回的结果是:

{
  "docs": [
    {
      "doc": {
        "_index": "_index",
        "_id": "_id",
        "_version": "-3",
        "_source": {
          "fqdn": "www.elastic.co",
          "url": {
            "registered_domain": "elastic.co",
            "top_level_domain": "co",
            "domain": "www.elastic.co",
            "subdomain": "www"
          }
        },
        "_ingest": {
          "timestamp": "2023-07-05T01:28:21.550629Z"
        }
      }
    }
  ]
}

猜你喜欢

转载自blog.csdn.net/UbuntuTouch/article/details/131548275