Significant Terms with multi word results

I have an ElasticSearch index that includes a "text" field that I would like to do ElasticSearch significant_terms aggregation on to determine meaningful terms and phrases from the "text" field. The problem I am facing, is the results are never a phrase, but instead always a one word term. The results may return something like: 'health' & 'care', but never 'health care'.

If anyone can please help me understand what I could be doing wrong.

Here is an example of my mapping:

{
  "mappings" : {
    "properties" : {
      "keyword" : {
        "type" : "text",
        "fields" : {
          "keyword" : {
            "type" : "keyword",
            "ignore_above" : 256
          }
        }
      },
      "text" : {
        "type" : "text",
        "fields" : {
          "keyword" : {
            "type" : "keyword",
            "ignore_above" : 256
          }
        },
        "fielddata": true,
        "index_phrases": true
      }
    }
  }
}

Here is an example of query to get significant terms:

{
  "query": {
    "bool": {
      "must": [
        {
          "match_phrase": {
            "keyword" : "health care"
          }
        }
      ]
    }
  },
  "size": 0,
  "aggs": {
      "test": {
        "significant_terms": {
          "field": "text"
        }
      }
  }
}

Two things:

  1. use the significant_text aggregation on text fields (along with the sampler aggregation to focus on just the top matches)
  2. Index your text using 2 word shingles to get phrases in results

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