# Significant Text Aggregation always returning zero buckets

**URL:** <https://discuss.elastic.co/t/significant-text-aggregation-always-returning-zero-buckets/283976>\
**Category:** Elasticsearch\
**Created:** [September 12, 2021, 1:44pm UTC](https://discuss.elastic.co/t/significant-text-aggregation-always-returning-zero-buckets/283976 "2021-09-12T13:44:17Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![BenB196](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/benb196/32/83401_2.png) [@BenB196](https://discuss.elastic.co/u/BenB196)\
**Post date:** [September 12, 2021, 1:44pm UTC](https://discuss.elastic.co/t/significant-text-aggregation-always-returning-zero-buckets/283976/1 "2021-09-12T13:44:17Z")

</div>

Hi All,

I'm attempting to use the [significant\_text aggregation](https://www.elastic.co/guide/en/elasticsearch/reference/7.14/search-aggregations-bucket-significanttext-aggregation.html) with a field that is stored as a text field and analyzed via the english analyzer but I'm having an issue where no buckets are being returned.

I'm essentially using the documented [basic use](https://www.elastic.co/guide/en/elasticsearch/reference/7.14/search-aggregations-bucket-significanttext-aggregation.html#_basic_use) example.

Here is the query I'm using:

```json
GET my_index/_search
{
  "query": {
    "match": {
      "Comment.english": "pay"
    }
  },
  "aggs": {
    "keywords": {
      "significant_text": {
        "field": "Comment.english"
      }
    }
  }
}

```

However, the output always returns zero buckets:

```json
{
  "took" : 46,
  "timed_out" : false,
  "_shards" : {
    "total" : 1,
    "successful" : 1,
    "skipped" : 0,
    "failed" : 0
  },
  "hits" : {
    "total" : {
      "value" : 2694,
      "relation" : "eq"
    },
    "max_score" : 3.9885752,
    "hits" : ...,
  "aggregations" : {
    "keywords" : {
      "doc_count" : 2694,
      "bg_count" : 21936,
      "buckets" : []
    }
  }
}

```

Would anyone have any ideas on why this is happening?

If I change the field to use the keyword version `Comment` it somewhat works, as it returns buckets, but it acts exactly like the `significant_terms` aggregation as it returns the keyword value rather than the individual analyzed words.

This also doesn't make much sense as in the docs for the [significant\_text aggregation](https://www.elastic.co/guide/en/elasticsearch/reference/7.14/search-aggregations-bucket-significanttext-aggregation.html#search-aggregations-bucket-significanttext-aggregation) it says its intended for `text` fields:

> - It is specifically designed for use on type `text` fields

Additional Information:

- Elasticsearch Version: 7.14.1

---

<div class="post-metadata">

**Author:** ![Mark\_Harwood](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mark_harwood/32/10538_2.png) [@Mark\_Harwood](https://discuss.elastic.co/u/Mark_Harwood)\
**Post date:** [September 12, 2021, 4:54pm UTC](https://discuss.elastic.co/t/significant-text-aggregation-always-returning-zero-buckets/283976/2 "2021-09-12T16:54:58Z")

</div>

Normally I’d use it on a text field eg “Comment”. It’s confused because comment.English is not a JSON field in the source and you have plain comment mapped as a keyword.  
Look at the ‘source\_fields param documented here [Significant text aggregation | Elasticsearch Guide [7.14] | Elastic](https://www.elastic.co/guide/en/elasticsearch/reference/7.14/search-aggregations-bucket-significanttext-aggregation.html#_dealing_with_source_and_index_mappings)

---

<div class="post-metadata">

**Author:** ![BenB196](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/benb196/32/83401_2.png) [@BenB196](https://discuss.elastic.co/u/BenB196)\
**Post date:** [September 12, 2021, 5:09pm UTC](https://discuss.elastic.co/t/significant-text-aggregation-always-returning-zero-buckets/283976/3 "2021-09-12T17:09:31Z")

</div>

Thanks @Mark_Harwood, using the `source_fields` param with `Comment` as the value did the trick. I didn't really think about the `source_fields` param here as it didn't occur to me that the multi-field mapping wasn't part of `_source`.

---

<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:** [October 10, 2021, 5:10pm UTC](https://discuss.elastic.co/t/significant-text-aggregation-always-returning-zero-buckets/283976/4 "2021-10-10T17:10:25Z")

</div>

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