I am new to elastic search, would someone kind enough to provide me a jason query to search last two months documents based on below data
"_source":{"date":"2016-08-01T10:24:29+0000","clientCode":"xxxx","countryCode":"AU"}
I am new to elastic search, would someone kind enough to provide me a jason query to search last two months documents based on below data
"_source":{"date":"2016-08-01T10:24:29+0000","clientCode":"xxxx","countryCode":"AU"}
Hi @avinsahlg,
Please, check the range query using date fields documentation.
It would be something like this:
a. Create the document
PUT test/_doc/1
{
  "date": "2019-08-12T10:24:29+0000",
  "clientCode": "xxxx",
  "countryCode": "AU"
}
b. Search for last 2 months:
GET test/_search
{
  "query": {
    "range": {
      "date": {
        "gte": "now/d-2M",
        "lte": "now/d"
      }
    }
  }
}
            This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
© 2020. All Rights Reserved - Elasticsearch
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.