Hi @arpansahoo,
I guess that what you are trying to achieve is not that easy or straightforward.
Please take a look to these resources and let me know your thoughts:
-
In this topic you will be able to see my 2 favourite options to solve this:
Birthday Querying -
This is also an interesting thread where a third option is explained:
Elasticsearch filtering by part of date - Stack Overflow
My suggestion would be to try to add a new field to your index called 'next_birthday', calculated and daily updated via a periodic job, as @danielmitterdorfer was suggesting in the shared resource. If you can manage that, then your queries would be simple and straightforward.
About the data you are working with, and having a date field with format MMddyyyy || MMdd, I wouldn't recommend to keep dates with both year and without year provided in the same date-field, as I believe it won't be giving you any extra value (internally all dates will have a year attached, so, omitting the year in some documents you wouldn't be able to make sense out of the data).
In such case, I would recommend to store the fields separately, as it's suggested here:
The third option mentioned before (storing as text and using wildcards in queries) could be valid if you don't have a big amount of users. Just keep an eye on the performance if you follow this approach.
Btw, how have you implemented the "search for exact birthday" query with your current data set?
Best regards,
Eduardo