Elasticsearch returns broken HTML tags when I use Highlighting Elasticsearch returns broken HTML tags when I use Highlighting elasticsearch elasticsearch

Elasticsearch returns broken HTML tags when I use Highlighting


I haven't tried it but I think you should specify the encoderin 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