indexing numeric field as both int and string in elastic search

五迷三道 提交于 2019-12-12 03:24:55

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!