1

I have a field in elastic search with "type": "integer"

If a string (or any NaN value is passed), I want to just have it default to some integer value (like 0).

Is there a way to do this in ES?

0

1 Answer 1

3

There is a way you can do it.

  1. First change coerce to false , so that even if string integer like "23" ( and not 23 ) , comes , it wont parse it. LINK - http://www.elastic.co/guide/en/elasticsearch/reference/1.4/mapping-core-types.html
  2. Next put null_value as 0 LINK - http://www.elastic.co/guide/en/elasticsearch/reference/1.4/mapping-core-types.html
Sign up to request clarification or add additional context in comments.

3 Comments

Will this work with non integer fields too? For example if I am expecting a nested object for some field but nothing is sent?
Btw, this didn't seem to work. I have an integer field, and i sent in "blah" for the value and it stored it as "blah" rather than my null_value
It would be stored this way in _source. I am talking about reverse index. WHen you search for blah , it wont work , but then null value will work.

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.