K2xL
K2xL

Reputation: 10290

ElasticSearch Mapping and Default Values When Wrong Format

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?

Upvotes: 1

Views: 3593

Answers (1)

Vineeth Mohan
Vineeth Mohan

Reputation: 19253

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

Upvotes: 3

Related Questions