Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

To Select documents having same startDate and endDate

I have some documents where in each document , there is a startDate and endDate date fields. I need all documents with both these value as same. I couldn't find any query which will help me to do it.

like image 268
Jagadeeshlal Avatar asked Sep 28 '22 12:09

Jagadeeshlal


1 Answers

Elasticsearch supports script filters, which you can use in this case . More Info Something like this is what you will need -

POST /<yourIndex>/<yourType>/_search?
{
    "query": {
        "filtered": {
           "filter": {
               "script": {
                  "script": "doc['startDate'].value == doc['endDate'].value"
               }
           }
        }
    }
}
like image 198
ManishKG Avatar answered Oct 04 '22 18:10

ManishKG