0
votes

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

1 Answers

3
votes

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"
            }
          }
        }
      }
    }
  }
}