Significant Text Aggregation always returning zero buckets

Hi All,

I'm attempting to use the significant_text aggregation 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 example.

Here is the query I'm using:

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

However, the output always returns zero buckets:

{
  "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 it says its intended for text fields:

  • It is specifically designed for use on type text fields

Additional Information:

  • Elasticsearch Version: 7.14.1

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

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.

1 Like

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