Skip to content

Instantly share code, notes, and snippets.

@stevesuo
Created May 27, 2011 20:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stevesuo/24bee84dbeae5359583f to your computer and use it in GitHub Desktop.
Save stevesuo/24bee84dbeae5359583f to your computer and use it in GitHub Desktop.
ElasticSearch date formats
#This works:
curl -XPUT 'http://localhost:9200/twitter/tweet/_mapping' -d '
{
"tweet" : {
"properties" : {
"user" : {"type" : "string", "index" : "not_analyzed"},
"post_date" : {"type" : "date","format" : "yyyy-MM-dd HH:mm:ss||MM/dd/yyyy||MM-dd-yyyy"},
"message" : {"type" : "string", "null_value" : "na"}
}
}
}'
curl -XPUT 'http://localhost:9200/twitter/tweet/1' -d '{
"user" : "kimchy",
"post_date" : "2009-11-15 14:12:12",
"message" : "trying out Elastic Search"
}'
#This doesn't work:
curl -XPUT 'http://localhost:9200/twitter/tweet/_mapping' -d '
{
"tweet" : {
"properties" : {
"user" : {"type" : "string", "index" : "not_analyzed"},
"post_date" : {"type" : "date","format" : "MM/dd/yyyy||MM-dd-yyyy||yyyy-MM-dd HH:mm:ss"},
"message" : {"type" : "string", "null_value" : "na"}
}
}
}'
curl -XPUT 'http://localhost:9200/twitter/tweet/1' -d '{
"user" : "kimchy",
"post_date" : "2009-11-15 14:12:12",
"message" : "trying out Elastic Search"
}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment