I have a document with a date type attribute (like the following)
{
"releaseDate": {
"time": "1990-02-01T00:00:00+0000",
}
}
I'm confident in doing some range query (date-math etc) so that if I'm looking for all the event in 1990, I can do the following range query
{
"query": {
"range": {
"releaseDate.time": {
"gte": "1990",
"lte": "1991"
}
}
}
}
I've noticed that Elasticsearch allow making a full-text search (match) on dates
match queries accept text/numerics/dates, analyzes them, and constructs a query. For example:
https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-match-query.html
But I've trouble understanding how to make the right query.
for example, if I search for the following match query
{
"query": {
"match": {
"attribute.releaseDate.time": "1990"
}
}
}
Zero results are returned from ES even if the date 1990-02-01T00:00:00 exists
But if I make the following
{
"query": {
"match": {
"attribute.releaseDate.time": "1990-02"
}
}
}
I've found my event.
My understanding is that with the search query, ES will expand my search as 1990-01-01T00:00:00+0000 that won't match the indexed value of 1990-02-01T00:00:00+0000 while in the second query the token is the same.
This will observation will lead to my questions:
There is any way to use the following query? - events occurred in 1990, dates that contain the year 1990 (without a range) - events occurred in February of any year - events occurred in February the 5th of any year
But I haven't found any working example (the only things I've seen is here https://discuss.elastic.co/t/mapping-date-field-as-multifiled-to-provide-date-query-and-full-text-search/80691)