Last active
December 19, 2015 06:19
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"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 | |
} | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"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