问题
How can I index a numeric field as both a integer and string using multi_field . As multi_field is deprecated now. How can I achieve the same using the "fields" field in version 2.x. I have heard that a field can be indexing and analysed in different ways using "fields". But can it be indexed as different types in elastic search?
The issue that I am facing is the classical numeric field search highlighting issue in elastic search.where I could not get numeric fields highlighting. So I want to index the field as string and int so that I can search, highlight and perform range operations on the data.
回答1:
You can use fields
like this to have your numeric as string
as well:
{
"mappings": {
"test": {
"properties": {
"my_numeric": {
"type": "integer",
"fields": {
"as_string": {
"type": "string",
"index": "not_analyzed"
}
}
}
}
}
}
}
来源:https://stackoverflow.com/questions/36715688/indexing-numeric-field-as-both-int-and-string-in-elastic-search