Highlight in Elasticsearch

As I stated in the comments I don't think this can be done in Elasticsearch. A highlighter just highlights the terms it matched and does no further postprocessing (And I found no evidence in the docs for Elasticsearch 2.3 that you could make it able to do so).

Anyway, my logical approach would be to add the <b>...</b> tags when you're rendering the HTML code.

{{ foreach hit in hits }}
<b>...</b> hit[content] <b>...</b>
{{ endfor }}

Something like this, just modify it to suit your template.


Use pre_tags and post_tags for this purpose.see configuring tags

GET /_search
{
    "query" : {
        "match": { "user": "kimchy" }
    },
    "highlight" : {
        "pre_tags" : ["<b>"],
        "post_tags" : ["</b>"],
        "fields" : {
            "content" : {}
        }
    }
}