Elasticsearch Highlighting on fields of data type integer, double ,long, float


(Nikesh) #1

Hi all,
I have indexed a field as both double and keyword. Searching is working fine but i have issues with highlighting. As i see, highlighting is not happening over datatypes other than text fields.
My mapping file is:

{
    "sorting": {
        "mappings": {
            "_doc": {
                "properties": {
                    "VALUE": {
                        "type": "double",
                        "fields": {
                            "keyword": {
                                "type": "keyword",
                                "ignore_above": 256
                            }
                        }
                    }
                }
            }
        }
    }
}

My search query is

{
	"query": {
    "bool": {"should": [


{
          "query_string": {
            "query":"\"230\"",
            "fields":[],
            "boost":"50"
					}
			}, {
          "multi_match": {
            "query":"230",
            "type":"phrase",
            "boost":"10",
            "slop":"2",
            "fields":[]
}},{
        	
          "multi_match": {
           "query":"230",
    			     "fields":[]
}}
] 
}
}, "highlight": {
        "type" : "unified",
        "fields": {
            "*": {}
        }
    }
}

and the results are

"hits": [
            {
                "_index": "sorting",
                "_type": "_doc",
                "_id": "2",
                "_score": 61,
                "_source": {
                    "VALUE": "230"
                },
                "highlight": {
                    "VALUE.keyword": [
                        "<em>230</em>"
                    ]
                }
            },
            {
                "_index": "sorting",
                "_type": "_doc",
                "_id": "1",
                "_score": 61,
                "_source": {
                    "VALUE": 230
                },
                "highlight": {
                    "VALUE.keyword": [
                        "<em>230</em>"
                    ]
                }
            }
        ]

Why is highlight not happening over Value and happening over value.keyword.
I wish to know why highlighting is not happening ovr fields of data type integer, double etc.