Search code examples
elasticsearchfull-text-search

Elasticsearch Full Text Search Top Phrases


I have a full text search engine built on elastic search. I need to find the top phrases in the engine. This would typically be named entities in the text indexed. How can this be done?


Solution

  • I would facet against a field to discover the most common text, phrases or words (depending on your index settings) are that appear within Elasticsearch' Inverted Index.

    Sample Facet

    {
      "size": 0,
      "query": {
        "match_all": {}
      },
      "facets": {
        "tag": {
          "terms": {
            "field": "firstname",
            "size": 6
          }
        }
      }
    }