The ElasticSearch documents just aren't clear on how to do this.
I indexed some tweets, and one of the fields, created_at, indexed as a string instead of a date. I can't find how to reindex with this change via a curl call. If reindexing is a complicated process, then I would much rather just delete what's there and start over. But, I can't find how to specify the field types either!
Any help is greatly appreciated.
You need to define a mapping using Put Mapping API.
curl -XPUT 'http://localhost:9200/twitter/_doc/_mapping' -H 'Content-Type: application/json' -d '
{
"_doc" : {
"properties" : {
"message" : {"type" : "text", "store" : true}
}
}
}
'
A date can be defined as follow:
curl -XPUT 'http://localhost:9200/twitter/_doc/_mapping' -H 'Content-Type: application/json' -d '
{
"_doc" : {
"properties" : {
"user" : {"type" : "keyword", "null_value" : "na"},
"message" : {"type" : "text"},
"postDate" : {"type" : "date"},
"priority" : {"type" : "integer"},
"rank" : {"type" : "float"}
}
}
}
'