Elastic Aggregate

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

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

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

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.

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

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

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