Currently im using ES 7.10
Creating a index and mapping
PUT /rathan_index
PUT /rathan_index/_mappings
{
"properties" : {
"Term__kt" : {
"type" : "nested",
"include_in_root" : true,
"properties" : {
"Fee_Amount" : {
"type" : "text",
"fields" : {
"raw" : {
"type" : "double"
}
}
}
}
},
"type" : {
"type" : "keyword"
}
}
}
Insert some data
POST /rathan_index/_doc/contracts-74900
{
"type": "contracts",
"Term__kt" : [
{
"Fee_Amount" : 105.75
}
]
}
POST /rathan_index/_doc/contracts-74901
{
"type": "contracts",
"Term__kt" : [
{
"Fee_Amount" : 105.75
}
]
}
GET rathan_index/_search
{
"from": 0,
"size": 1000,
"_source": [
"*__kt.*"
],
"track_total_hits": true,
"query": {
"function_score": {
"query": {
"bool": {
"filter": {
"bool": {
"must": [
{
"term": {
"type": "contracts"
}
}
]
}
},
"should": [
{
"query_string": {
"query": "0105.75",
"type": "best_fields",
"fields": [
"*__kt.*"
],
"lenient": true,
"default_operator": "AND",
"boost": 3
}
},
{
"query_string": {
"query": "0105.75",
"type": "phrase_prefix",
"fields": [
"*__kt.*"
],
"lenient": true,
"boost": 2
}
},
{
"query_string": {
"query": "0105.75",
"fields": [
"*__kt.*"
],
"lenient": true,
"type": "best_fields"
}
}
],
"minimum_should_match": 1
}
}
}
},
"min_score": 0.000001,
"highlight": {
"fields": {
"*": {
"type": "plain"
}
}
}
}
The result comes with 105.75 but its not getting higlighted
{
"took" : 565,
"timed_out" : false,
"_shards" : {
"total" : 5,
"successful" : 5,
"skipped" : 0,
"failed" : 0
},
"hits" : {
"total" : {
"value" : 2,
"relation" : "eq"
},
"max_score" : 4.0,
"hits" : [
{
"_index" : "rathan_index",
"_type" : "_doc",
"_id" : "contracts-74900",
"_score" : 4.0,
"_source" : {
"Term__kt" : [
{
"Fee_Amount" : 105.75
}
]
},
"highlight" : {
"type" : [
"<em>contracts</em>"
]
}
},
{
"_index" : "rathan_index",
"_type" : "_doc",
"_id" : "contracts-74901",
"_score" : 4.0,
"_source" : {
"Term__kt" : [
{
"Fee_Amount" : 105.75
}
]
},
"highlight" : {
"type" : [
"<em>contracts</em>"
]
}
}
]
}
}
I'm assuming there is a implicit conversion that's happening which is converting 0105.75 to 105.75 .
But i want it to highlighted regardless. Can i please get a solution for this.
Thanks in advance