I have indexed a document containing integers .
Mapping of these fields are :
"INTEGER_FIELD": {
"type": "integer",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
}
Search query is :
{
"from": 0,
"size": 10,
"query": {
"bool": {
"should": [
{
"query_string": {
"query": "\"0\"",
"fields": [
"INTEGER_FIELD"
],
"boost": "2000"
}
},
{
"query_string": {
"query": "*0*",
"analyzer": "whitespace",
"fields": [
"INTEGER_FIELD"
]
}
}
],
"minimum_should_match": 1
}
},
"highlight": {
"type": "unified",
"fields": {
"INTEGER_FIELD": {}
}
}
}
My doubts are:
1. When the above query is used, "INTEGER_FIELD" is highlighted,
The highlight result fetched is :
"highlight": {
"INTEGER_FIELD": [
"<em>0</em>"
]
}
2. When only the first query_string is used i.e.,
{
"from": 0,
"size": 10,
"query": {
"bool": {
"should": [
{
"query_string": {
"query": "\"0\"",
"fields": [
"INTEGER_FIELD"
],
"boost": "2000"
}
}
],
"minimum_should_match": 1
}
},
"highlight": {
"type": "unified",
"fields": {
"INTEGER_FIELD": {}
}
}
}
The document is retrieved/fetched but there is no highlighting present.
3. When only the second query_string is used i.e.,
{
"from": 0,
"size": 10,
"query": {
"bool": {
"should": [
{
"query_string": {
"query": "*0*",
"analyzer": "whitespace",
"fields": [
"INTEGER_FIELD"
]
}
}
],
"minimum_should_match": 1
}
},
"highlight": {
"type": "unified",
"fields": {
"INTEGER_FIELD": {}
}
}
}
The document is not fetched and hence nothing is highlighted
I am failing to understand the behaviour of highlighting here.
From what i understand, Elasticsearch provides highlight only for text fields. Why is Integer fields getting highlighted and Why is it getting highlighted only when I am using wildcard character?
Please let me know if I am going wrong somewhere