How dates work in Elasticsearch
PUT /reviews/_doc/2
{
"rating": 4.5,
"content": "Not bad. Not bad at all!",
"product_id": 123,
"created_at": "2015-03-27",
"author": {
"first_name": "Average",
"last_name": "Joe",
"email": "avgjoe@example.com"
}
}
Supplying both a date and time
PUT /reviews/_doc/3
{
"rating": 3.5,
"content": "Could be better",
"product_id": 123,
"created_at": "2015-04-15T13:07:41Z",
"author": {
"first_name": "Spencer",
"last_name": "Pearson",
"email": "spearson@example.com"
}
}
Specifying the UTC offset
PUT /reviews/_doc/4
{
"rating": 5.0,
"content": "Incredible!",
"product_id": 123,
"created_at": "2015-01-28T09:21:51+01:00",
"author": {
"first_name": "Adam",
"last_name": "Jones",
"email": "adam.jones@example.com"
}
}
Supplying a timestamp (milliseconds since the epoch)
# Equivalent to 2015-07-04T12:01:24Z
PUT /reviews/_doc/5
{
"rating": 4.5,
"content": "Very useful",
"product_id": 123,
"created_at": 1436011284000,
"author": {
"first_name": "Taylor",
"last_name": "West",
"email": "twest@example.com"
}
}
GET /reviews/_search
{
"query": {
"match_all": {}
}
}