Answer the question
In order to leave comments, you need to log in
How to filter nested object in ES?
Hello.
How to filter nested object in ES?
There are for example 3 products with options.
{
name: "Product 1",
price: 10.00
options: [
{
value: "red",
option: {
name: "color"
}
},
{
value: "square",
option: {
name: "figure"
}
},
{
value: 100,
option: {
name: "height"
}
}
]
},
{
name: "Product 2",
price: 20.00
options: [
{
value: "black",
option: {
name: "color"
}
},
{
value: "circle",
option: {
name: "figure"
}
},
{
value: 200,
option: {
name: "height"
}
}
]
},
{
name: "Product 3",
price: 30.00
options: [
{
value: "blue",
option: {
name: "color"
}
},
{
value: "triangle",
option: {
name: "figure"
}
},
{
value: 300,
option: {
name: "height"
}
}
]
}
{
"query": {
"bool": {
"filter": [
/** Тут дополнительные фильтры **/
]
}
},
"aggs": {
"list": {
"terms": {
"field": "options.value"
}
}
}
}
Answer the question
In order to leave comments, you need to log in
https://www.elastic.co/guide/en/elasticsearch/refe... so about.
The only thing is that it would be nice to make your options nested, otherwise the filter may not work correctly, since after the filter ALL options values will be taken.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question