gpt4 book ai didi

bash - "jq: error: Cannot index array with string"使用jq从ElasticSearch结果中获取数据

转载 作者:行者123 更新时间:2023-12-02 20:03:15 25 4
gpt4 key购买 nike

我尝试从 json 中获取 listaObjeto

这是我的 json 的摘录:

{
"took": 42,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"skipped": 0,
"failed": 0
},
"hits": {
"total": 1,
"max_score": 11.2367325,
"hits": [
{
"_index": "provflogs-2019.03.26",
"_type": "Portal",
"_id": "SQGEumkBYgyBeVm_SiGe",
"_score": 11.2367325,
"_source": {
"siglaSistema": "SRPO",
"dataPesquisa": "2019-03-26T12:00:25.896-0300",
"ipRequisitante": "104.238.179.249",
"listaObjeto": [
"UB711395572YP",
"OG461051611BR",
"RG968790315CN"
],
"loginUsuario": "USER1",
"metodoRequisitado": "buscaEventos"
}
}
]
}
}

这是我收到的错误:

jq '.hits.hits._source.listaObjeto' jq: error: Cannot index array with string

最佳答案

.hits.hits 是一个数组,因此您需要添加 [] 来映射它:

.hits.hits[]._source.listaObjeto

关于bash - "jq: error: Cannot index array with string"使用jq从ElasticSearch结果中获取数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55361298/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com