我在弹性搜索索引中有以下文档:
{
"type": "foo",
"components": [{
"id": "1234123", ,
"data_collections": [{
"date_time": "2020-03-02T08:14:48+00:00",
"group": "1",
"group_description": "group1",
"measures": [{
"measure_name": "MEASURE_1",
"actual": "23.34"
}, {
"measure_name": "MEASURE_2",
"actual": "5"
}, {
"measure_name": "MEASURE_3",
"actual": "string_message"
}, {
"measure_name": "MEASURE_4",
"actual": "another_string"
}
]
},
{
"date_time": "2020-03-03T08:14:48+00:00",
"group": "2",
"group_description": "group2",
"measures": [{
"measure_name": "MEASURE_1",
"actual": "23.34"
}, {
"measure_name": "MEASURE_4",
"actual": "foo"
}, {
"measure_name": "MEASURE_5",
"actual": "bar"
}, {
"measure_name": "MEASURE_6",
"actual": "4"
}
]
}
]
}
]
}
现在我正在尝试找出该文档的映射和查询,因此结果将仅包含我感兴趣的组和 measure_names。到目前为止,我可以查询,但我总是会检索整个文档,即不可行,因为措施数组可能非常大,而且大多数时候我想要一个小子集。
例如,我正在搜索带有"group": "1"
and的文档,"measure_name": "MEASURE_"
我想要实现的结果如下所示:
{
"_id": "oiqwueou8931283u12",
"_source": {
"type": "foo",
"components": [{
"id": "1234123", ,
"data_collections": [{
"date_time": "2020-03-02T08:14:48+00:00",
"group": "1",
"group_description": "group1",
"measures": [{
"measure_name": "MEASURE_1",
"actual": "23.34"
}
]
}
]
}
]
}
}
我认为接近我正在寻找的是source
参数,但据我所知,没有办法过滤像{"measure_name": {"value": "MEASURE_1"}}
谢谢。