# Elastic Aggregate

**URL:** <https://discuss.elastic.co/t/elastic-aggregate/316485>\
**Category:** Elasticsearch\
**Created:** [October 13, 2022, 4:20am UTC](https://discuss.elastic.co/t/elastic-aggregate/316485 "2022-10-13T04:20:38Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![edhbs31](https://avatars.discourse-cdn.com/v4/letter/e/41988e/32.png) [@edhbs31](https://discuss.elastic.co/u/edhbs31)\
**Post date:** [October 13, 2022, 4:20am UTC](https://discuss.elastic.co/t/elastic-aggregate/316485/1 "2022-10-13T04:20:38Z")

</div>

Hi Guys,  
I am very new at elastic.. and i need some help or advice..

i have elastic's json result like this:

"results": [  
{  
"discount": "",  
},

And Aggregate like this..  
"data": [  
{  
"count": 17081,  
"value": ""  
},  
]

I want to remove aggregate with value "" without removing the result with value ""

So the result will be like this:  
"results": [  
{  
"discount": "",  
},

//aggregate  
"data": [

]

here is my query

facets":{"discount":{"type":"value","size":15}}

What should i do ?  
Big thanks

---

<div class="post-metadata">

**Author:** ![Carlos\_D](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/carlos_d/32/126245_2.png) [@Carlos\_D](https://discuss.elastic.co/u/Carlos_D)\
**Post date:** [October 13, 2022, 8:48am UTC](https://discuss.elastic.co/t/elastic-aggregate/316485/2 "2022-10-13T08:48:42Z")

</div>

Hi @edhbs31 , welcome to the community!

You can't remove the aggregate for "" without also removing the result, as the way to do this would be to use a [filter](https://www.elastic.co/guide/en/app-search/current/filters.html) to remove the values and facets you don't need.

Another option would be just to discard the "" value you receive on the facets. Is this an option?

---

<div class="post-metadata">

**Author:** ![edhbs31](https://avatars.discourse-cdn.com/v4/letter/e/41988e/32.png) [@edhbs31](https://discuss.elastic.co/u/edhbs31)\
**Post date:** [October 13, 2022, 9:17am UTC](https://discuss.elastic.co/t/elastic-aggregate/316485/3 "2022-10-13T09:17:38Z")

</div>

Hi Carlos Thanks for your advice,  
unfortunately, there where lot of result that is not "" and also we still need "" result,  
We just need to remove "" value in aggregate..  
So confused for this case

---

<div class="post-metadata">

**Author:** ![Carlos\_D](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/carlos_d/32/126245_2.png) [@Carlos\_D](https://discuss.elastic.co/u/Carlos_D)\
**Post date:** [October 13, 2022, 1:35pm UTC](https://discuss.elastic.co/t/elastic-aggregate/316485/4 "2022-10-13T13:35:34Z")

</div>

What is your use case? You are probably using the App Search API from Javascript or through one of our language clients.

Are you not able to filter out the facet programatically on your end? It seems doable just comparing the facet value with "" to filter it out.

---

<div class="post-metadata">

**Author:** ![edhbs31](https://avatars.discourse-cdn.com/v4/letter/e/41988e/32.png) [@edhbs31](https://discuss.elastic.co/u/edhbs31)\
**Post date:** [October 13, 2022, 1:55pm UTC](https://discuss.elastic.co/t/elastic-aggregate/316485/5 "2022-10-13T13:55:29Z")

</div>

Hi Carlos,  
i'am using go as our backend.  
My main use case is just i have to discard value "" only in aggregates, without losing value "" in result..  
sorry. I think i'am still little bit confused about it

---

<div class="post-metadata">

**Author:** ![joemcelroy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/joemcelroy/32/103757_2.png) [@joemcelroy](https://discuss.elastic.co/u/joemcelroy)\
**Post date:** [October 17, 2022, 9:40am UTC](https://discuss.elastic.co/t/elastic-aggregate/316485/6 "2022-10-17T09:40:26Z")

</div>

hey @edhbs31,

Carlos is suggesting that once you have received the response from App Search API, you transform the facet values to exclude the empty value entry before returning it back to the client.

Just to double check, are you using App search API or the Elasticsearch APIs?

Joe

---

<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 14, 2022, 9:40am UTC](https://discuss.elastic.co/t/elastic-aggregate/316485/7 "2022-11-14T09:40:32Z")

</div>

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