okfn / timemapper

Create and share elegant timelines and timemaps fast
http://timemapper.okfnlabs.org/
MIT License
274 stars 60 forks source link

Create mapping for ES index with (some) field types defined #29

Closed rufuspollock closed 12 years ago

rufuspollock commented 12 years ago

Just encountered the following error:

Error on upsert: MapperParsingException[Failed to parse [start]]; nested: MapperParsingException[failed to parse date field, tried both date format [dateOptionalTime], and timestamp number]; nested: IllegalArgumentException[Invalid format: "1st September 2009" is malformed at "st September 2009"];

Some web searches later had clarified that the problem was that ES had "guessed" from data originally given to it (napoleon data) that start attribute on note object was a datetime when in fact it is a string (start_parsed is the field guaranteed to be a proper date time)

Solution is to provide an explicit mapping when creating the index, and set these fields to be strings:

http://www.elasticsearch.org/guide/reference/api/admin-indices-create-index.html

Results can be checked by doing

 curl -s -XGET 'http://localhost:9200/_cluster/state?pretty=true'