Hello,
I have some product like this
{
"id_product" : "180",
"name" : "Domane AL 3 femme",
"manufacturer" : "TREK",
"cat_path" : "Product>377~velos~Vélos>35~route~Route>44~course~Course",
"variants" : [
{
"id_product_attribute" : "140601",
"manufacturer" : "TREK",
"gender" : [
"Femme"
],
"collection" : "2020",
"offer" : "Actions",
"size" : "56",
"color" : "PACIFIC",
"warehouse" : [ ],
"stock" : 0,
"stock_magasin" : 0
},
{
"id_product_attribute" : "140602",
"manufacturer" : "TREK",
"gender" : [
"Femme"
],
"collection" : "2020",
"offer" : "Actions",
"size" : "54",
"color" : "PACIFIC",
"warehouse" : [ ],
"stock" : 0,
"stock_magasin" : 0
},
{
"id_product_attribute" : "140603",
"manufacturer" : "TREK",
"gender" : [
"Femme"
],
"collection" : "2020",
"offer" : "Actions",
"size" : "52",
"color" : "PACIFIC",
"warehouse" : [ ],
"stock" : 0,
"stock_magasin" : 0
},
{
"id_product_attribute" : "140604",
"manufacturer" : "TREK",
"gender" : [
"Femme"
],
"collection" : "2020",
"offer" : "Actions",
"size" : "50",
"color" : "PACIFIC",
"warehouse" : [ ],
"stock" : 0,
"stock_magasin" : 0
},
{
"id_product_attribute" : "140605",
"manufacturer" : "TREK",
"gender" : [
"Femme"
],
"collection" : "2020",
"offer" : "Actions",
"size" : "47",
"color" : "PACIFIC",
"warehouse" : [
"Web",
"Lausanne"
],
"stock" : 1,
"stock_magasin" : 1
},
{
"id_product_attribute" : "142249",
"manufacturer" : "TREK",
"gender" : [
"Femme"
],
"collection" : "2020",
"offer" : "Actions",
"size" : "47",
"color" : "BLANC CRISTAL",
"warehouse" : [ ],
"stock" : 0,
"stock_magasin" : 0
},
{
"id_product_attribute" : "142250",
"manufacturer" : "TREK",
"gender" : [
"Femme"
],
"collection" : "2020",
"offer" : "Actions",
"size" : "50",
"color" : "BLANC CRISTAL",
"warehouse" : [ ],
"stock" : 0,
"stock_magasin" : 0
},
{
"id_product_attribute" : "142251",
"manufacturer" : "TREK",
"gender" : [
"Femme"
],
"collection" : "2020",
"offer" : "Actions",
"size" : "52",
"color" : "BLANC CRISTAL",
"warehouse" : [ ],
"stock" : 0,
"stock_magasin" : 0
},
{
"id_product_attribute" : "142252",
"manufacturer" : "TREK",
"gender" : [
"Femme"
],
"collection" : "2020",
"offer" : "Actions",
"size" : "54",
"color" : "BLANC CRISTAL",
"warehouse" : [ ],
"stock" : 0,
"stock_magasin" : 0
},
{
"id_product_attribute" : "142253",
"manufacturer" : "TREK",
"gender" : [
"Femme"
],
"collection" : "2020",
"offer" : "Actions",
"size" : "56",
"color" : "BLANC CRISTAL",
"warehouse" : [ ],
"stock" : 0,
"stock_magasin" : 0
}
],
"stock" : 1
}
I have a query to retrieve aggs ... and I don't understand the result. Here is the POST for the agg.
POST prestashop_ch/_search
{
"size": 10,
"aggs": {
"agg_size": {
"filter": {
"bool": {
"must": [
{
"term": {
"cat_path.tree": "Product>377~velos~Vélos>35~route~Route>44~course~Course"
}
},
{
"nested": {
"path": "variants",
"query": {
"bool": {
"must": [
{
"terms": {
"variants.gender": [
"Femme"
]
}
},
{
"terms": {
"variants.manufacturer": [
"TREK"
]
}
},
{
"term": {
"variants.warehouse": "Lausanne"
}
}
]
}
}
}
}
]
}
},
"aggs": {
"facets": {
"nested": {
"path": "variants"
},
"aggs": {
"values": {
"terms": {
"field": "variants.size"
},
"aggs": {
"top_reverse_nested": {
"reverse_nested": {}
}
}
}
}
}
}
}
},
"post_filter": {
"bool": {
"must": [
{
"term": {
"cat_path.tree": "Product>377~velos~Vélos>35~route~Route>44~course~Course"
}
},
{
"nested": {
"path": "variants",
"query": {
"bool": {
"must": [
{
"terms": {
"variants.gender": [
"Femme"
]
}
},
{
"terms": {
"variants.manufacturer": [
"TREK"
]
}
},
{
"terms": {
"variants.warehouse": [
"Lausanne"
]
}
},
{
"terms": {
"variants.size": [
"47"
]
}
}
]
}
}
}
}
]
}
}
}
And the result
{
"took" : 1,
"timed_out" : false,
"_shards" : {
"total" : 1,
"successful" : 1,
"skipped" : 0,
"failed" : 0
},
"hits" : {
"total" : 1,
"max_score" : 0.0,
"hits" : [ ]
},
"aggregations" : {
"agg_size" : {
"doc_count" : 1,
"facets" : {
"doc_count" : 10,
"values" : {
"doc_count_error_upper_bound" : 0,
"sum_other_doc_count" : 0,
"buckets" : [
{
"key" : "47",
"doc_count" : 2,
"top_reverse_nested" : {
"doc_count" : 1
}
},
{
"key" : "50",
"doc_count" : 2,
"top_reverse_nested" : {
"doc_count" : 1
}
},
{
"key" : "52",
"doc_count" : 2,
"top_reverse_nested" : {
"doc_count" : 1
}
},
{
"key" : "54",
"doc_count" : 2,
"top_reverse_nested" : {
"doc_count" : 1
}
},
{
"key" : "56",
"doc_count" : 2,
"top_reverse_nested" : {
"doc_count" : 1
}
}
]
}
}
}
}
}
I don't understand why I have other size than the "47" as this is the only one that match the filter.
How can I solve that ? (the problem is that if I display this agg and the user select the size "50" i makes of course no result.
Thanks a lot