美文网首页
es ingest创建数据处理API使用

es ingest创建数据处理API使用

作者: 奋斗的韭菜汪 | 来源:发表于2021-01-20 20:51 被阅读0次

    ingest使用场景:

    1、数据写入预处理
    2、更新数据
    3、重建索引数据
    4、通用公用函数功能模块
    processors:内置pipeline支持的数据加工处理器
    set:使用结合来增加数据

    DELETE _ingest/pipeline/area_01
    PUT _ingest/pipeline/area_01
    {
      "description": "增加地区",
      "processors": [
        {
          "set": {
            "field": "country",
            "value": "CN"
          }
        },
        {
          "set": {
            "field": "provice",
            "value": "zj"
          }
        },
        {
          "set": {
            "field": "city",
            "value": "hz"
          }
        }
        
      ]
    }
    GET _ingest/pipeline/area_01
    
    PUT test_ingest/_doc/1?pipeline=area_01
    {
      "companyId":1,
      "companyName":"##集团"
    }
    GET test_ingest/_search
    

    GET test_ingest/_search结果:

    {
      "took" : 0,
      "timed_out" : false,
      "_shards" : {
        "total" : 1,
        "successful" : 1,
        "skipped" : 0,
        "failed" : 0
      },
      "hits" : {
        "total" : {
          "value" : 1,
          "relation" : "eq"
        },
        "max_score" : 1.0,
        "hits" : [
          {
            "_index" : "test_ingest",
            "_type" : "_doc",
            "_id" : "1",
            "_score" : 1.0,
            "_source" : {
              "country" : "CN",
              "companyId" : 1,
              "city" : "hz",
              "companyName" : "##集团",
              "provice" : "zj"
            }
          }
        ]
      }
    }
    

    _simulate模拟器

    POST _ingest/pipeline/area_01/_simulate
    {
      "docs": [
        {
          "_source":{
            "name":"lisi"
          }
        }
        ]
    }
    

    结果:

    {
      "docs" : [
        {
          "doc" : {
            "_index" : "_index",
            "_type" : "_doc",
            "_id" : "_id",
            "_source" : {
              "country" : "CN",
              "city" : "hz",
              "provice" : "zj",
              "name" : "lisi"
            },
            "_ingest" : {
              "timestamp" : "2021-01-19T14:18:32.554Z"
            }
          }
        }
      ]
    }
    

    相关文章

      网友评论

          本文标题:es ingest创建数据处理API使用

          本文链接:https://www.haomeiwen.com/subject/qcaczktx.html