[英]ElasticSearch-Kibana : filter array by key
I have data with one parameter which is an array. 我有一个参数是一个数组的数据。 I know that objects in array are not well supported in Kibana, however I would like to know if there is a way to filter that array with only one value for the key. 我知道数组中的对象在Kibana中得不到很好的支持,但我想知道是否有一种方法可以只用一个值来过滤该数组。 I mean : 我的意思是 :
This is a json for exemple : 这是一个json例如:
{
"_index": "index",
"_type": "data",
"_id": "8",
"_version": 2,
"_score": 1,
"_source": {
"envelope": {
"version": "0.0.1",
"submitter": "VF12RBU1D53087510",
"MetaData": {
"SpecificMetaData": [
{
"key": "key1",
"value": "94"
},
{
"key": "key2",
"value": "0"
}
]
}
}
}
}
And I would like to only have the data which contains key1 in my SpecificMetaData array in order to plot them. 我想只在我的SpecificMetaData数组中包含key1的数据才能绘制它们。 For now, when I plot SpecificMetaData.value it takes all the values of the array (value of key1 and key2) and doesn't propose SpecificMetaData.value1 and SpecificMetaData.value2. 现在,当我绘制SpecificMetaData.value时,它获取数组的所有值(key1和key2的值),并且不提出SpecificMetaData.value1和SpecificMetaData.value2。
If you need more information, tell me. 如果您需要更多信息,请告诉我。 Thank you. 谢谢。
you may need to map your data to mappings so as SpecificMetaData should act as nested_type and inner_hits of nested filter can supply you with objects which have key1. 您可能需要映射您的数据映射,从而SpecificMetaData应采取行动nested_type和inner_hits嵌套过滤器可以与具有key1的对象提供给您。
PUT envelope_index
{
"mappings": {
"document_type": {
"properties": {
"envelope": {
"type": "object",
"properties": {
"version": {
"type": "text"
},
"submitter": {
"type": "text"
},
"MetaData": {
"type": "object",
"properties": {
"SpecificMetaData": {
"type": "nested"
}
}
}
}
}
}
}
}
}
POST envelope_index/document_type
{
"envelope": {
"version": "0.0.1",
"submitter": "VF12RBU1D53087510",
"MetaData": {
"SpecificMetaData": [{
"key": "key1",
"value": "94"
},
{
"key": "key2",
"value": "0"
}
]
}
}
}
POST envelope_index/_search
{
"query": {
"bool": {
"must": [
{
"nested": {
"inner_hits": {},
"path": "envelope.MetaData.SpecificMetaData",
"query": {
"bool": {
"must": [
{
"term": {
"envelope.MetaData.SpecificMetaData.key": {
"value": "key1"
}
}
}
]
}
}
}
}
]
}
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.