从完全限定域名 (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 | - | 处理器的标识符。 对于调试和指标很有用。 |
示例
以下示例说明了注册域处理器的使用:
1. POST _ingest/pipeline/_simulate
2. {
3. "pipeline": {
4. "processors": [
5. {
6. "registered_domain": {
7. "field": "fqdn",
8. "target_field": "url"
9. }
10. }
11. ]
12. },
13. "docs": [
14. {
15. "_source": {
16. "fqdn": "www.example.ac.uk"
17. }
18. }
19. ]
20. }
上面的命令返回:
1. {
2. "docs": [
3. {
4. "doc": {
5. "_index": "_index",
6. "_id": "_id",
7. "_version": "-3",
8. "_source": {
9. "fqdn": "www.example.ac.uk",
10. "url": {
11. "registered_domain": "example.ac.uk",
12. "top_level_domain": "ac.uk",
13. "domain": "www.example.ac.uk",
14. "subdomain": "www"
15. }
16. },
17. "_ingest": {
18. "timestamp": "2023-07-05T01:27:04.720322Z"
19. }
20. }
21. }
22. ]
23. }
我们再来测试一下 www.elastic.co 的情况:
1. POST _ingest/pipeline/_simulate
2. {
3. "pipeline": {
4. "processors": [
5. {
6. "registered_domain": {
7. "field": "fqdn",
8. "target_field": "url"
9. }
10. }
11. ]
12. },
13. "docs": [
14. {
15. "_source": {
16. "fqdn": "www.elastic.co"
17. }
18. }
19. ]
20. }
上面返回的结果是:
1. {
2. "docs": [
3. {
4. "doc": {
5. "_index": "_index",
6. "_id": "_id",
7. "_version": "-3",
8. "_source": {
9. "fqdn": "www.elastic.co",
10. "url": {
11. "registered_domain": "elastic.co",
12. "top_level_domain": "co",
13. "domain": "www.elastic.co",
14. "subdomain": "www"
15. }
16. },
17. "_ingest": {
18. "timestamp": "2023-07-05T01:28:21.550629Z"
19. }
20. }
21. }
22. ]
23. }