# Aggregation using execution\_hit: map automatically filtered empty string key

**URL:** <https://discuss.elastic.co/t/aggregation-using-execution-hit-map-automatically-filtered-empty-string-key/95445>\
**Category:** Elasticsearch\
**Created:** [August 2, 2017, 4:00am UTC](https://discuss.elastic.co/t/aggregation-using-execution-hit-map-automatically-filtered-empty-string-key/95445 "2017-08-02T04:00:43Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![wd3790281](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/wd3790281/32/20712_2.png) [@wd3790281](https://discuss.elastic.co/u/wd3790281)\
**Post date:** [August 2, 2017, 4:00am UTC](https://discuss.elastic.co/t/aggregation-using-execution-hit-map-automatically-filtered-empty-string-key/95445/1 "2017-08-02T04:00:43Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![polyfractal](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/polyfractal/32/48162_2.png) [@polyfractal](https://discuss.elastic.co/u/polyfractal)\
**Post date:** [August 2, 2017, 8:11pm UTC](https://discuss.elastic.co/t/aggregation-using-execution-hit-map-automatically-filtered-empty-string-key/95445/2 "2017-08-02T20:11:46Z")

</div>

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](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](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](https://www.elastic.co/guide/en/elasticsearch/guide/current/_dealing_with_null_values.html)

---

<div class="post-metadata">

**Author:** ![wd3790281](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/wd3790281/32/20712_2.png) [@wd3790281](https://discuss.elastic.co/u/wd3790281)\
**Post date:** [August 7, 2017, 1:50am UTC](https://discuss.elastic.co/t/aggregation-using-execution-hit-map-automatically-filtered-empty-string-key/95445/4 "2017-08-07T01:50:21Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![wd3790281](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/wd3790281/32/20712_2.png) [@wd3790281](https://discuss.elastic.co/u/wd3790281)\
**Post date:** [August 7, 2017, 2:50am UTC](https://discuss.elastic.co/t/aggregation-using-execution-hit-map-automatically-filtered-empty-string-key/95445/5 "2017-08-07T02:50:10Z")

</div>

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.

---

<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:** [September 4, 2017, 2:50am UTC](https://discuss.elastic.co/t/aggregation-using-execution-hit-map-automatically-filtered-empty-string-key/95445/6 "2017-09-04T02:50:11Z")

</div>

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