我是 Elastic Search 的新手,我的数据格式如下:
索引映射
{
"company:product:index": {
"aliases": {},
"mappings": {
"company:product:mapping": {
"properties": {
"attribute_heel-style": {
"properties": {
"label": {
"type": "keyword"
},
"name": {
"type": "keyword"
},
"source": {
"type": "keyword"
},
"value": {
"type": "keyword"
},
"value_label": {
"type": "keyword"
}
}
}
}
}
}
}
}
索引数据
{
"attribute_heel-style": [
{
"name": "heel-style",
"label": "Heel Style",
"value": "stiletto",
"value_label": "Stiletto"
},
{
"name": "heel-style",
"label": "Heel Style",
"value": "wedge"
"value_label": "Wedge"
},
... // a bunch of other objects in this array as well
]
}
我想创建一个查询,以便我可以过滤数组中键“value_label”的值为“Wedge”的所有对象。我怎样才能做到这一点?
编辑:找到解决方案!下面发帖。感谢@EsCoder。
{
"query": {
"bool": {
"filter": [
{
"bool": {
"must": [
{
"term": {
"attribute_heel-style.value_label": "wedge"
}
}
]
}
}
]
}
}
}