Hi all,
I'm facing an error and I really don't understand the problem. I'm using ES6.8. If any one could help me, I would really appreciate.
PUT prestashop_ch
{
"settings": {
"number_of_shards": 1,
"number_of_replicas": 0
},
"mapping": {
"_doc": {
"properties": {
"collections": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword"
}
}
},
"genres": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword"
}
}
},
"manufacturer": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword"
}
}
},
"id_product": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"link_rewrite": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"name": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"reference": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"variants": {
"type": "nested",
"properties": {
"id_product_attribute": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"variation_reference": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"string_facet": {
"type": "nested",
"properties": {
"facet-name": {
"type": "keyword"
},
"facet-value": {
"type": "keyword"
}
}
},
"stock": {
"type": "long"
},
"stock_magasin": {
"type": "long"
}
}
}
}
}
}
}
Here is a result of a search of 1 document
{
"took" : 1,
"timed_out" : false,
"_shards" : {
"total" : 1,
"successful" : 1,
"skipped" : 0,
"failed" : 0
},
"hits" : {
"total" : 3254,
"max_score" : 1.0,
"hits" : [
{
"_index" : "prestashop_ch",
"_type" : "_doc",
"_id" : "15363",
"_score" : 1.0,
"_source" : {
"id_product" : "15363",
"name" : "Manchettes Norain",
"manufacturer" : "SPORTFUL",
"reference" : "1-69603",
"link_rewrite" : "manchettes-norain",
"genres" : [
"Femme"
],
"collections" : "2018",
"variants" : [
{
"string_facet" : [
{
"facet-name" : "id_product_attribute",
"facet-value" : "119533"
},
{
"facet-name" : "variation_reference",
"facet-value" : "2001990788747"
},
{
"facet-name" : "manufacturer",
"facet-value" : "SPORTFUL"
},
{
"facet-name" : "genres",
"facet-value" : [
"Femme"
]
},
{
"facet-name" : "color",
"facet-value" : "NOIR"
},
{
"facet-name" : "size",
"facet-value" : "XL"
},
{
"facet-name" : "warehouses",
"facet-value" : [ ]
}
],
"stock" : 0,
"stock_magasin" : 0
},
{
"string_facet" : [
{
"facet-name" : "id_product_attribute",
"facet-value" : "119534"
},
{
"facet-name" : "variation_reference",
"facet-value" : "2001990788754"
},
{
"facet-name" : "manufacturer",
"facet-value" : "SPORTFUL"
},
{
"facet-name" : "genres",
"facet-value" : [
"Femme"
]
},
{
"facet-name" : "size",
"facet-value" : "L"
},
{
"facet-name" : "color",
"facet-value" : "NOIR"
},
{
"facet-name" : "warehouses",
"facet-value" : [
"Neuchâtel"
]
}
],
"stock" : 1,
"stock_magasin" : 1
},
{
"string_facet" : [
{
"facet-name" : "id_product_attribute",
"facet-value" : "119535"
},
{
"facet-name" : "variation_reference",
"facet-value" : "2001990788761"
},
{
"facet-name" : "manufacturer",
"facet-value" : "SPORTFUL"
},
{
"facet-name" : "genres",
"facet-value" : [
"Femme"
]
},
{
"facet-name" : "size",
"facet-value" : "M"
},
{
"facet-name" : "color",
"facet-value" : "NOIR"
},
{
"facet-name" : "warehouses",
"facet-value" : [
"Neuchâtel"
]
}
],
"stock" : 2,
"stock_magasin" : 2
},
{
"string_facet" : [
{
"facet-name" : "id_product_attribute",
"facet-value" : "119536"
},
{
"facet-name" : "variation_reference",
"facet-value" : "2001990788778"
},
{
"facet-name" : "manufacturer",
"facet-value" : "SPORTFUL"
},
{
"facet-name" : "genres",
"facet-value" : [
"Femme"
]
},
{
"facet-name" : "size",
"facet-value" : "S"
},
{
"facet-name" : "color",
"facet-value" : "NOIR"
},
{
"facet-name" : "warehouses",
"facet-value" : [
"Neuchâtel"
]
}
],
"stock" : 1,
"stock_magasin" : 1
}
]
}
}
]
}
}
The query
POST prestashop_ch/_search
{
"size": 0,
"aggs": {
"all_facets": {
"nested": {
"path": "variants.string_facet"
},
"aggs": {
"names": {
"terms": {
"field": "variants.string_facet.facet-name"
},
"aggs": {
"values": {
"terms": {
"field": "variants.string_facet.facet-value"
}
}
}
}
}
}
}
}
And the result ...
{
"error": {
"root_cause": [
{
"type": "aggregation_execution_exception",
"reason": "[nested] nested path [variants.string_facet] is not nested"
}
],
"type": "search_phase_execution_exception",
"reason": "all shards failed",
"phase": "query",
"grouped": true,
"failed_shards": [
{
"shard": 0,
"index": "prestashop_ch",
"node": "-upIp7RWRaSsr7oIdpytVw",
"reason": {
"type": "aggregation_execution_exception",
"reason": "[nested] nested path [variants.string_facet] is not nested"
}
}
]
},
"status": 500
}