0

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 Answer 1

3

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"
            }
          }
        }
      }
    }
  }
}
Sign up to request clarification or add additional context in comments.

1 Comment

I don't think this is valid in elastic current version. I got this:no handler for type [string] declared on field [as_string]"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.