Skip to content

Instantly share code, notes, and snippets.

@johnnypeck
Last active December 19, 2015 06:19
Show Gist options
  • Save johnnypeck/5910688 to your computer and use it in GitHub Desktop.
Save johnnypeck/5910688 to your computer and use it in GitHub Desktop.
Elastic search filter and with two ranges does not work. The idea is that if the leaseStartDate is less than the date submitted AND the leaseEndDate is greater than the date submitted this should return the document. It does not seem that the AND is actually working as intended.
{
"property" : {
"properties" : {
"id" : {
"type" : "string",
"include_in_all" : true
},
"leases" : {
"type" : "nested",
"include_in_all" : true,
"properties" : {
"leaseEndDate" : {
"type" : "date",
"format" : "dateOptionalTime",
"include_in_all" : false
},
"leaseStartDate" : {
"type" : "date",
"format" : "dateOptionalTime",
"include_in_all" : false
}
}
},
"managedStatus" : {
"type" : "string",
"include_in_all" : true
}
}
}
}
{
"query": {
"filtered": {
"query": {
"match": {
"id": "184"
}
},
"filter": {
"nested": {
"path": "leases",
"filter": {
"and": [{
"range": {
"leaseStartDate": {
"lte": "2012-03-16T15:00:00-04:00"
}
},
"range": {
"leaseEndDate": {
"gte": "2012-04-30T15:00:00-04:00"
}
}
}]
}
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment