Elastic aggregation search result filters

Hello everyone
We have index mapping like that:

{
	"test2": {
		"mappings": {
			"products": {
				"properties": {
					"category": {
						"properties": {
							"id": {
								"type": "long"
							},
							"name": {
								"type": "text",
								"fields": {
									"keyword": {
										"type": "keyword",
										"ignore_above": 256
									}
								}
							}
						}
					},
					"category_char": {
						"properties": {
							"2": {
								"properties": {
									"characteristic_name": {
										"type": "text",
										"fields": {
											"keyword": {
												"type": "keyword",
												"ignore_above": 256
											}
										}
									},
									"data_type": {
										"type": "text",
										"fields": {
											"keyword": {
												"type": "keyword",
												"ignore_above": 256
											}
										}
									},
									"filter": {
										"type": "long"
									},
									"id": {
										"type": "long"
									},
									"unit": {
										"type": "text",
										"fields": {
											"keyword": {
												"type": "keyword",
												"ignore_above": 256
											}
										}
									}
								}
							},
							"characteristic_name": {
								"type": "text",
								"fields": {
									"keyword": {
										"type": "keyword",
										"ignore_above": 256
									}
								}
							},
							"data_type": {
								"type": "text",
								"fields": {
									"keyword": {
										"type": "keyword",
										"ignore_above": 256
									}
								}
							},
							"filter": {
								"type": "long"
							},
							"id": {
								"type": "long"
							},
							"unit": {
								"type": "text",
								"fields": {
									"keyword": {
										"type": "keyword",
										"ignore_above": 256
									}
								}
							}
						}
					},
					"category_id": {
						"type": "long"
					},
					"created_at": {
						"type": "text",
						"fields": {
							"keyword": {
								"type": "keyword",
								"ignore_above": 256
							}
						}
					},
					"description": {
						"type": "text",
						"fields": {
							"keyword": {
								"type": "keyword",
								"ignore_above": 256
							}
						}
					},
					"id": {
						"type": "long"
					},
					"product_char": {
						"properties": {
							"char_id": {
								"type": "long"
							},
							"data_type": {
								"type": "text",
								"fields": {
									"keyword": {
										"type": "keyword",
										"ignore_above": 256
									}
								}
							},
							"filter": {
								"type": "long"
							},
							"product_id": {
								"type": "long"
							},
							"unit": {
								"type": "text",
								"fields": {
									"keyword": {
										"type": "keyword",
										"ignore_above": 256
									}
								}
							},
							"value": {
								"type": "text",
								"fields": {
									"keyword": {
										"type": "keyword",
										"ignore_above": 256
									}
								},
								"fielddata": true
							}
						}
					},
					"title": {
						"type": "text",
						"fields": {
							"keyword": {
								"type": "keyword",
								"ignore_above": 256
							}
						},
						"fielddata": true
					},
					"value": {
						"type": "text",
						"fielddata": true
					}
				}
			}
		}
	}
}

then I do query like that:

{
   "query":{
       "multi_match":{
           "query": "Samsung",
           "fuzziness": "AUTO",
           "fields": ["title^2", "tags^3", "description"]
       }
   },
   "aggs": {
       "categories": {
           "terms" : {
               "field": "category_id"
           },
           "aggs": {
               "characteristics" :{
                   "terms" :{
                       "field": "product_char.char_id",
                       "size": 100000
                   },
                   "aggs" :{
                       "value": {
                           "terms" :{
                               "field" : "product_char.value.keyword",
                               "size" : 100000
                           }
                       }
                   }
               }
           }
       }
   }
}

My question is, why I get clones of characteristics value in each characteristic in response?

My goal is get uniq characteristics and aggregate uniq values of each characteristic of all products I got from my query.
I need it to make search results filters on my site.

Thanks for any help...

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.