Pipo
Pipo

Reputation: 5591

Query for searching a specific date in elasticsearch

In elasticsearch, there is a date range query and fuzzy date query, however I don't see a query for querying a specific date.

Do you know if that type of query exists?

Upvotes: 1

Views: 1983

Answers (1)

RoiHatam
RoiHatam

Reputation: 896

Use the following mapping:

"properties": {
    "myDate": {
        "type": "date",
        "format": "dd-MM-yyyy"
    }
}

The query for searching the exact date would be:

"query": {
    "term": {
        "myDate": {
            "value": "10-10-2010"
        }
    }
}

Upvotes: 2

Related Questions