search - Elasticsearch highlighting with wildcard does not work as expected -


i using elasticsearch highlight sometime , having problems. here highlight query:

"highlight" : { "pre_tags" : [ "<span class=\"mark\">" ], "post_tags" : [ "</span>" ], "order" : "score", "encoder" : "html", "require_field_match" : false, "fields" : {   "*" : { } } 

}

i specifying * in fields because need highlighting possible fields , not want specify them all. problem if use field query highlights fields not queried, example if query for:

name:macdonalds 

it highlight also:

name:**macdonalds** description: **macdonalds** fast food... 

i using query_string query, , cannot set require_field_match true since searching free test in fields , if set parameter true not highlight anything...

any suggestions? has stumble on such issue?

well, have managed workaround issue (following @will comment) when specifying explicitly fields want highlighting on in query , setting require_field_match" : true highlight works expected :) little strange... works. way has issue highlighting fields not strings, pay attention.

 {       "from" : 0,       "size" : 10,       "query" : {         "query_string" : {           "query" : "some query",           "fields" : [ "field1", "field2", ... ],           "use_dis_max" : true         }       },       "highlight" : {         "pre_tags" : [ "<span class=\"mark\">" ],         "post_tags" : [ "</span>" ],         "order" : "score",         "encoder" : "html",         "require_field_match" : true,         "fields" : {           "*" : { }         }       }     } 

Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -