I use Elasticsearch 7.9 and I want to highlight an exact search filed with simple query string query, for a document.
The following query doesn't highlight words in the document, although these words are in the document.
I tried to add this line in highlight.fields, but it changes nothing.
"text_html": {"number_of_fragments": 0}
How to correct it ? Thanks.
Configuration:
"mappings": {
"properties": {
"text_html": {
"type": "text",
"analyzer": "english",
"fields": {
"exact": {
"type": "text",
"analyzer": "english_exact"
}
}
}
}
}
And my query:
{
"highlight": {
"fields": {
"text_html.exact": {"number_of_fragments": 0}
}
},
"_source": [
"id",
"text_html"
],
"query": {
"bool": {
"must": [
{
"simple_query_string": {
"query": "\"use case\"",
"fields": [
"text_html"
],
"quote_field_suffix": ".exact"
}
}
],
"filter": [
{
"term": {"id": "case111"}
}
]
}
}
}