Elasticsearch not merging highlights -


i have elasticsearch field index using ngram tokenizer. unexpectedly, elasticsearch not merge adjacent highlights. example search term 854511 following highlights

da v50 v335 auf v331 j06a <mark>85</mark><mark>45</mark><mark>11</mark> 

while i'd expect this

da v50 v335 auf v331 j06a <mark>854511</mark> 

here analyzers:

additional_analyzers = { analyzer: {       ngram_analyzer: {           tokenizer: :ngram_tokenizer,           filter: 'lowercase'       }}, tokenizer: {       ngram_tokenizer: {type: :ngram,                         min_gram: 2,                         max_gram: 20,                         token_chars: [ 'letter', 'digit', 'symbol', 'punctuation' ]       }} }  settings analysis: additional_analyzers   mappings     indexes :name, type: 'multi_field'       indexes :name, type: :string, analyzer: :ngram_analyzer, term_vector: :with_positions_offsets       indexes :not_analyzed, type: :string, index: :not_analyzed     end     indexes :mdc, type: :string, index: :not_analyzed     indexes :description, type: :string, analyzer: :html_ngram_analyzer, term_vector: :with_positions_offsets     indexes :created_at, type: :date   end end 

try plain highlighter.

if try following query:

{   "query": {     "match": {       "name": "854511"     }   },   "highlight": {     "fields": {       "name": {         "pre_tags": [           "<mark>"         ],         "post_tags": [           "</mark>"         ],         "fragment_size": 150,         "number_of_fragments": 1,         "type": "plain"       }     }   } } 

you desired result:

"hits": [   {     "_index": "test",     "_type": "test",     "_id": "1",     "_score": 0.1856931,     "_source": {       "name": "da v50 v335 auf v331 j06a 854511"     },     "highlight": {       "name": [         "da v50 v335 auf v331 j06a <mark>854511</mark>"       ]     }   } ] 

Comments

Popular posts from this blog

javascript - Karma not able to start PhantomJS on Windows - Error: spawn UNKNOWN -

Nuget pack csproj using nuspec -

c# - Display ASPX Popup control in RowDeleteing Event (ASPX Gridview) -