Highlight list of terms containing hyphens and whitespaces

Hello,
I am realizing a system for keywords matching with ES 7.6 using highlight.
This is my mappings code:

    "mappings": {
        "properties": {
            "title": { 
                "type": "text" 
            },
            "description": { 
                "type": "text", 
                "fielddata": True 
            }
        }
    }

and this is the query I use:

"query" : {
	"match": { "description": LIST_OF_KEYWORDS }
},
"highlight" : {
	"pre_tags" : ["<key>"],
	"post_tags" : ["</key>"],
	"fields" : {
		"description" : {"number_of_fragments" : 0 }
	}
}

where LIST_OF_KEYWORDS contains some keywords like "water-proof, dry, anti fogging".
So, my intention is to highlight the whole keywords like this:

  • <key>water-proof</key> insted of <key>water</key>, <key>proof</key>
  • <key>anti fogging</key> insted of <key>anti</key>, <key>fogginf</key>

Some idea?

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.