Partial date search on Date Of Birth Fields

Hi,
I have one field which is dateofbirth whose mapping is something like below
"dateofbirth" : {
"type" : "date",
"fields" : {
"tokens" : {
"type" : "text"
}
},
"ignore_malformed" : true,
"format" : "yyyy-MM-dd"
},
I have a use case where i need to search on the basis of yyyydd & yyyy & yyyyMM, Does any one know how to apply analyzer in such case, so that tokens can be created for searching.

A date gets converted to the milliseconds since the epoch (midnight in 1970) and a query will be a range query. You can specify the format when querying, that should just include the year or month. See https://www.elastic.co/guide/en/elasticsearch/reference/7.4/query-dsl-range-query.html#range-query-field-params

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.