Hi all,
I am testing the latest Elasticsearch 7.16.3 and encountered an issue.
I have a keyword type field with the lowercase normaliser. When I get highlight on the keyword field, Highlighting seems not to be applied on the _source value even though I explicitly set force_source = true. To reproduce the issue,
PUT my-index-000001
{
"mappings": {
"properties": {
"tags": {
"type": "keyword",
"normalizer": "lowercase"
},
"keywords": {
"type": "keyword"
},
"description": {
"type": "text"
}
}
}
}
POST my-index-000001/_doc
{
"tags": "Elastic",
"keywords": "Elastic",
"description": "Elastic search elastic"
}
This is my search request:
GET my-index-000001/_search
{
"from": 0,
"size": 20,
"query": {
"bool": {
"must": [
{
"query_string": {
"query": "elastic",
"fields": [
"keywords",
"tags",
"description"
]
}
}
]
}
},
"highlight": {
"number_of_fragments": 0,
"force_source" : true,
"fields": {
"keywords": {},
"tags": {},
"description": {}
}
}
}
This is what I have got
{
"took": 2,
"timed_out": false,
"_shards": {
"total": 1,
"successful": 1,
"skipped": 0,
"failed": 0
},
"hits": {
"total": {
"value": 1,
"relation": "eq"
},
"max_score": 0.39556286,
"hits": [
{
"_index": "my-index-000001",
"_type": "_doc",
"_id": "Ujt6aX4BXCJVOiKe7UXr",
"_score": 0.39556286,
"_source": {
"tags": "Elastic",
"keywords": "Elastic",
"description": "Elastic search elastic"
},
"highlight": {
"description": [
"<em>Elastic</em> search <em>elastic</em>"
],
"tags": [
"<em>elastic</em>"
]
}
}
]
}
}
What I expected for the highlight value on "tags" is "Elastic" because I set "force_source" : true and the tags in _source is "Elastic".
Please let me know if I misunderstood something or it is a bug.
Many thanks in advance,
Youngmi