15

I have a date field setup in my mapping like this:

"groupsAssignedDate" : {
    "type" : "date",
    "format" : "MM-dd-YYYY"
}

In my app, the field groupsAssignedDate is set to the empty string initially. When a group is assigned, a unix timestamp is generated and stored in the field. I'm trying to use elasticsearch's bulk update function to bring in a bunch of documents with a groupsAssignedDate of "" because no groups have been assigned yet. Elasticsearch won't index the docs though. This is in the log file:

Failed to parse [groupsAssignedDate]
...
failed to parse date field [], tried both date format [MM-dd-YYYY], and timestamp number

It appears elasticsearch supports the JSON null value...do I need to switch my docs from using "" to null or is there some way I can support using the empty string instead?

Troy
  • 1,799
  • 3
  • 20
  • 29

1 Answers1

23

Sounds like you may have answered this yourself. Just using null rather than "" in the date field should work.

If that's an issue, maybe consider this from
https://www.elastic.co/guide/en/elasticsearch/reference/current/ignore-malformed.html#ignore-malformed-setting

The index.mapping.ignore_malformed global setting can be set on the index level to allow to ignore malformed content globally across all mapping types (malformed content example is trying to index a string value as a numeric type).

EDIT Edited the URL above to jump to the new information.

EDIT Edited the URL above again to jump to the new information.

Phil
  • 2,797
  • 1
  • 24
  • 30
  • Even I am facing this issue. Where should I set this value? – BSingh Sep 13 '13 at 21:49
  • 1
    Try taking a look at the index settings section half way down this page: http://www.elasticsearch.org/guide/reference/setup/configuration/ – Phil Sep 24 '13 at 15:27
  • @Phil Nothing at this link regarding setting ignore_malformed so assuming it has changed? Anyone else have any ideas? – steven.levey May 12 '15 at 09:08
  • @steven.levey - the info is at the end of the page in the final section here: http://www.elastic.co/guide/en/elasticsearch/reference/current/mapping.html#mapping-settings - I'll edit the answer – Phil May 12 '15 at 15:18
  • Link is now found at: https://www.elastic.co/guide/en/elasticsearch/reference/current/ignore-malformed.html#ignore-malformed-setting – pctj101 Mar 21 '16 at 03:59