小编Sam*_*m G的帖子

使用jq从ElasticSearch结果中的_source文档中提取数据

我正在阅读这个StackOverFlow讨论,将JSON转换为CSV,这似乎很棒,但是我无法使用基本的jq来工作。.我不确定我在做什么错。我已经尝试了基本的操作,但是我无法破解错误。这是我在Shell脚本中的ES查询

curl -XGET 'http://es-1:9200/data_latest/customer/_search?pretty' -H 'Content-Type: application/json' -d'
{
"_source": ["customer_app_version", "customer_num_apps", "customer_name","app_disk_size_bytes","app_memory_capacity_bytes"],
    "query": {
        "bool": {
            "must": [{
                "term": {
                    "is_app_customer": {
                        "value": "true"
                    }
                }
            }]
        }
    },
    "aggs": {
        "Customer_UUID": {
            "terms": {
                "field": "customer_uuid",
                "size": 100
            }
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

Shell脚本输出

{
  "took": 8,
  "timed_out": false,
  "_shards": {
    "total": 5,
    "successful": 5,
    "failed": 0
  },
  "hits": {
    "total": 6171,
    "max_score": 1.8510876,
    "hits": [
      {
        "_index": "data_latest_v1",
        "_type": "customer",
        "_id": "0003245-4844-9015-1z2e-d4ae5234rd56",
        "_score": 1.8510876,
        "_source": …
Run Code Online (Sandbox Code Playgroud)

csv shell json curl jq

3
推荐指数
1
解决办法
2312
查看次数

标签 统计

csv ×1

curl ×1

jq ×1

json ×1

shell ×1