Aggregation using execution_hit: map automatically filtered empty string key

Hi guys,

I'm using execution_hint: map in my aggregation to ensure my aggs run in fast speed. However, I have a key which is "". But the aggregation result doesn't contain that bucket. I'm using terms aggregation. Do it automatically filtered by es? Anyone have encountered this problem?

When you say "", do you mean it's a blank field? Null? Or was that a space?

Elasticsearch by default treats blank and null values as if they don't exist, so nothing is indexed.

You can use null_value as a way to index placeholders for null values: https://www.elastic.co/guide/en/elasticsearch/reference/current/null-value.html. Or when running the terms aggregation, you can specify a missing parameter which defines a placeholder to use when fields are missing/empty/null: https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-terms-aggregation.html#_missing_value_12

Not quite the same, but related docs on null/missing/exist here: https://www.elastic.co/guide/en/elasticsearch/guide/current/_dealing_with_null_values.html

Thank you for your reply. "" here is an empty string. The field value is an empty string. I have tried the missing value filter. It seems that it will only get the doc without the field when aggregation, not include the doc with the value"", which is an empty string.

Besides, when i using execution_hint: global_ordinals. The empty value "" is kept as a bucket. But once using map as execution_hit, the "" empty value is filtered? Why? Beacuse map is aggregating using the raw value of the field?

In my application, only using map as execution_hint can satisfied the speed requirements. So I have to using that.

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