# Between/Range query issue

**URL:** <https://discuss.elastic.co/t/between-range-query-issue/90972>\
**Category:** Elasticsearch\
**Created:** [June 27, 2017, 2:09pm UTC](https://discuss.elastic.co/t/between-range-query-issue/90972 "2017-06-27T14:09:35Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![iluvcode](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/iluvcode/32/24929_2.png) [@iluvcode](https://discuss.elastic.co/u/iluvcode)\
**Post date:** [June 27, 2017, 2:09pm UTC](https://discuss.elastic.co/t/between-range-query-issue/90972/1 "2017-06-27T14:09:35Z")

</div>

document in Elasticsearch index

```
{
                "_index": "elasticsearchlocal",
                "_type": "deliveryprojection",
                "_id": "11102",
                "_score": null,
                "_source": {
                    "zipCode": "60015",
                    "prioritySeq": 1,
                    "siteName": "MW",
                    "residentialFlag": true,                 
                    "wareHouseKeyId": "Primary",                      
                    "warehouseCutOffs": [                        
                        {
                            "cutOffFrom": 4.000277777777778,
                            "cutOffTo": 5,
                            "additionalTransitDay": 0,
                            "nextDayShipping": false
                        },
                        {
                            "cutOffFrom": 5.000277777777778,
                            "cutOffTo": 6,
                            "additionalTransitDay": 0,
                            "nextDayShipping": false
                        },
                        {
                            "cutOffFrom": 6.000277777777778,
                            "cutOffTo": 7,
                            "additionalTransitDay": 0,
                            "nextDayShipping": false
                        },
                        {
                            "cutOffFrom": 7.000277777777778,
                            "cutOffTo": 8,
                            "additionalTransitDay": 0,
                            "nextDayShipping": false
                        },
                        {
                            "cutOffFrom": 8.000277777777777,
                            "cutOffTo": 9,
                            "additionalTransitDay": 0,
                            "nextDayShipping": false
                        },
                        {
                            "cutOffFrom": 9.000277777777777,
                            "cutOffTo": 10,
                            "additionalTransitDay": 0,
                            "nextDayShipping": false
                        },
                        {
                            "cutOffFrom": 10.000277777777777,
                            "cutOffTo": 11,
                            "additionalTransitDay": 0,
                            "nextDayShipping": false
                        },
                        {
                            "cutOffFrom": 11.000277777777777,
                            "cutOffTo": 12,
                            "additionalTransitDay": 0,
                            "nextDayShipping": false
                        },
                        {
                            "cutOffFrom": 12.000277777777777,
                            "cutOffTo": 13,
                            "additionalTransitDay": 0,
                            "nextDayShipping": false
                        },
                        {
                            "cutOffFrom": 13.000277777777777,
                            "cutOffTo": 14,
                            "additionalTransitDay": 0,
                            "nextDayShipping": false
                        },
                        {
                            "cutOffFrom": 14.000277777777777,
                            "cutOffTo": 15,
                            "additionalTransitDay": 0,
                            "nextDayShipping": false
                        },
                        {
                            "cutOffFrom": 15.000277777777777,
                            "cutOffTo": 16,
                            "additionalTransitDay": 0,
                            "nextDayShipping": false
                        },
                        {
                            "cutOffFrom": 16.00027777777778,
                            "cutOffTo": 17.25,
                            "additionalTransitDay": 0,
                            "nextDayShipping": false
                        },
                        {
                            "cutOffFrom": 20.25027777777778,
                            "cutOffTo": 21,
                            "additionalTransitDay": 1,
                            "nextDayShipping": true
                        },
                        {
                            "cutOffFrom": 21.000277777777775,
                            "cutOffTo": 22.25,
                            "additionalTransitDay": 1,
                            "nextDayShipping": true
                        },
                        {
                            "cutOffFrom": 22.250277777777775,
                            "cutOffTo": 23,
                            "additionalTransitDay": 1,
                            "nextDayShipping": false
                        },
                        {
                            "cutOffFrom": 23.000277777777775,
                            "cutOffTo": 0,
                            "additionalTransitDay": 1,
                            "nextDayShipping": false
                        }
                    ],
                    "id": 11102,
                    "hasMoreRecord": false,
                    "contentTypeId": 0
                },
                "sort": [
                    1
                ]
            }

```

When I execute below range query, above record is being returned from Elasticsearch. Above document doesn't have warehouseCutOffs.cutOffFrom and warehouseCutOffs.cutOffTo in between 18.777590778666666 value.  
I am not sure why below query is returning this record. How can I exclude above document when this query is executed ?  
Any help is greatly appreciated.

```
{
    	"size": 3,
    	"sort": [{
    		"prioritySeq": {
    			"order": "asc"
    		}
    	}],
    	"query": {
    		"bool": {
    			"must": [{
    				"term": {
    					"zipCode": {
    						"value": "60015"
    					}
    				}
    			}, {
    				"term": {
    					"residentialFlag": {
    						"value": true
    					}
    				}
    			}, {
    				"range": {
    					"warehouseCutOffs.cutOffFrom": {
    						"lt": 18.777590778666666
    					}
    				}
    			}, {
    				"range": {
    					"warehouseCutOffs.cutOffTo": {
    						"gt": 18.777591334222222
    					}
    				}
    			}]
    		}
    	}
    }
```

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 25, 2017, 2:09pm UTC](https://discuss.elastic.co/t/between-range-query-issue/90972/2 "2017-07-25T14:09:52Z")

</div>

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