date - Elasticsearch - Incoming birthdays -


i'm new elasticsearch , i'm stuck query.

i want next (now+3d) birthdays among users. looks simple it's not because have birthdate of users.

how can compare months , day directly in query when have birthdate (eg: 1984-04-15 or 2015-04-15 sometimes) ?

my field mapping:

"birthdate": {     "format": "dateoptionaltime",     "type": "date" } 

my actual query doesn't work @ all:

{    "query": {       "range": {          "birthdate": {             "format": "dd-mm",             "gte": "now",             "lte": "now+3d"          }       }    } } 

i saw post elasticsearch filtering part of date i'm not big fan of solution, , prefer instead of wilcard "now+3d"

maybe can do script ?

"format" field added in 1.5.0 version of elasticsearch. if version below 1.5.0 format not work. had same problem had send email on user's birthday , using version 1.4.4. created separate dob field stored date in "dd-mm" format.

we changed mapping of date field:

put /user {   "mappings": {    "user": {      "properties": {       "dob": {        "type": "date",        "format": "dd-mm"        }      }    }   } } 

then can search:

 /user/_search  {    "query": {     "filtered": {      "filter": {       "range": {         "date": {           "from": "01-01",           "to": "01-01",           "include_upper" : true           }         }       }     }   } } 

Comments

Popular posts from this blog

python - pip install -U PySide error -

arrays - C++ error: a brace-enclosed initializer is not allowed here before ‘{’ token -

cytoscape.js - How to add nodes to Dagre layout with Cytoscape -