【问题标题】:Jolt - change format of elasticsearch responseJolt - 更改弹性搜索响应的格式
【发布时间】:2017-06-07 21:42:11
【问题描述】:

这应该是显而易见的,因为 Jolt 主要是为了转换 ES ,mongodb 响应而构建的。但我无法弄清楚

我想解析 ES 响应并仅打印选定的字段。例如,我想将响应转换为

{
"time" : 63,
"totalhits":100,
"0";{ response1.field1,response1.field2},
"1";{ response2.field1,response2.field2},
"2";{ response3.field1,response3.field2},
}


  {
  "took" : 63,
  "timed_out" : false,
  "_shards" : {
    "total" : 5,
    "successful" : 5,
    "failed" : 0
  },
  "hits" : {
    "total" : 1000,
    "max_score" : null,
    "hits" : [ {
      "_index" : "bank",
      "_type" : "account",
      "_id" : "0",
      "sort": [0],
      "_score" : null,
      "_source" : {"account_number":0,"balance":16623,"firstname":"Bradshaw","lastname":"Mckenzie","age":29,"gender":"F","address":"244 Columbus Place","employer":"Euron","email":"bradshawmckenzie@euron.com","city":"Hobucken","state":"CO"}
    }, {
      "_index" : "bank",
      "_type" : "account",
      "_id" : "1",
      "sort": [1],
      "_score" : null,
      "_source" : {"account_number":1,"balance":39225,"firstname":"Amber","lastname":"Duke","age":32,"gender":"M","address":"880 Holmes Lane","employer":"Pyrami","email":"amberduke@pyrami.com","city":"Brogan","state":"IL"}
    }, ...
    ]
  }
    }

目前我得到的规范文件是

[
  {
    "operation": "shift",
    "spec": {
      "hits": {
        "*": {
          "*": "&"
        }
      }
    }
}
]

【问题讨论】:

    标签: elasticsearch jolt


    【解决方案1】:

    想通了。

    [
      {
        "operation": "shift",
        "spec": {
          "took": "took",
          "hits": {
            "total": "total_hits",
            "hits": {
              "*": {
                "_source": {
                  "country": "Response[&2].country",
                  "city": "Response[&2].city",
                  "year": "Response[&2].year"
                }
              }
            }
          }
        }
      }
    ]
    

    【讨论】:

      猜你喜欢
      • 2016-02-02
      • 1970-01-01
      • 1970-01-01
      • 2019-03-28
      • 1970-01-01
      • 1970-01-01
      • 2018-01-30
      • 2017-01-26
      • 2019-05-18
      相关资源
      最近更新 更多