# Elastic aggregation search result filters

**URL:** <https://discuss.elastic.co/t/elastic-aggregation-search-result-filters/154784>\
**Category:** Elasticsearch\
**Created:** [October 31, 2018, 9:25am UTC](https://discuss.elastic.co/t/elastic-aggregation-search-result-filters/154784 "2018-10-31T09:25:19Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Baikal\_Irkutsk](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/baikal_irkutsk/32/37138_2.png) [@Baikal\_Irkutsk](https://discuss.elastic.co/u/Baikal_Irkutsk)\
**Post date:** [October 31, 2018, 9:25am UTC](https://discuss.elastic.co/t/elastic-aggregation-search-result-filters/154784/1 "2018-10-31T09:25:19Z")

</div>

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...

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [November 28, 2018, 9:31am UTC](https://discuss.elastic.co/t/elastic-aggregation-search-result-filters/154784/2 "2018-11-28T09:31:39Z")

</div>

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