0

I have an elasticsearch index with the following data:

"The A-Team" (as an example)

My index settings are :

"index": {
    "number_of_shards": "1",
    "provided_name": "tyh.tochniyot",
    "creation_date": "1481039136127",
    "analysis": {
      "analyzer": {
        "whitespace_analyzer": {
          "type": "whitespace"
        },
        "ngram_analyzer": {
          "type": "custom",
          "tokenizer": "ngram_tokenizer"
        }
      },
      "tokenizer": {
        "ngram_tokenizer": {
          "type": "ngram",
          "min_gram": "3",
          "max_gram": "7"
        }
      }
    },

When i search for :

_search
{
"from": 0,
"size": 20,
"track_scores": true,
"highlight": {
  "fields": {
    "*": {
      "fragment_size": 100,
      "number_of_fragments": 10,
      "require_field_match": false
    }
  }
},
"query": {
  "match": {
    "_all": {
      "query": "Tea"
    }
  }
}

I expect to get the highlight result :

    "highlight": {
      "field": [
        "The A-<em>Tea</em>m"
      ]
}

But i dont get any highlight at all.

The reason i am using whitespace for search and ngram for indexing is that i dont want in search phase to break the word i am searching, like if i am searching for "Team" it will find me "Tea","eam","Team"

Thank you

IB.
  • 1,019
  • 3
  • 13
  • 21

1 Answers1

0

The problem was that my Analyzer and search Analyzer were running on the _all filed. When i placed Analyzer attribute on the specific fields the Highlight started working.

IB.
  • 1,019
  • 3
  • 13
  • 21