Elasticsearch returns broken HTML tags when I use Highlighting
I haven't tried it but I think you should specify the encoder
in the highlight part to html
.
{ "query": { "filtered": { "query": { "multi_match": { "query": "matrix", "fields": ["title","content"] } }, "filter": { "term": { "content_type": "page" } } } }, "highlight" : { "order" : "score", "fields" : { "content" : {"fragment_size" : 150, "number_of_fragments" : 3} }, "encoder": "html" }}
See: https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-highlighting.html