I am currently experimenting with using a Raspberry Pi 4 to ingest Reddit data in real-time. It is working very well, but I'm having a hard time finding concise documentation on how to use date ranges for a URI search.
For example, to set the range for the last hour I can do this:
I would expect this to return results since I'm searching for a range for the entire year, but no documents are returned. What is the correct syntax when searching exact dates or datetime values?
The mapping for the created_utc field is as follows:
My guess is that because you defined "format":"epoch_second" in your mapping, elasticsearch can only parse dates which are epoch_second and not any other text.
DELETE test
PUT test
{
"mappings": {
"properties": {
"date": {
"type": "date",
"format": "dd/MM/yyyy||epoch_second"
}
}
}
}
PUT test/_doc/1
{
"date": "26/12/1971"
}
GET test/_search?q=date:["01/12/1971" TO "01/01/1972"]
Note that you can't use "epoch_second||dd/MM/yyyy". Only the first format is applied.
Thank you David! I appreciate the reply and really enjoy your responses in this forum. You do a great job helping others with their questions. From one developer to another, you do a great service to the community.
My thought process in this example was that Elasticsearch would be able to internally translate the datetime to the appropriate epoch value.
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.