# Range based query on number type

**URL:** <https://discuss.elastic.co/t/range-based-query-on-number-type/225763>\
**Category:** Elastic Search\
**Tags:** elastic-app-search\
**Created:** [March 30, 2020, 11:37pm UTC](https://discuss.elastic.co/t/range-based-query-on-number-type/225763 "2020-03-30T23:37:50Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![nathanwfish](https://avatars.discourse-cdn.com/v4/letter/n/8e7dd6/32.png) [@nathanwfish](https://discuss.elastic.co/u/nathanwfish)\
**Post date:** [March 30, 2020, 11:37pm UTC](https://discuss.elastic.co/t/range-based-query-on-number-type/225763/1 "2020-03-30T23:37:51Z")

</div>

My schema includes field "mileage" with a type set to "number".  
When I run a query like the following, I get all documents, not just those in the range.

```auto
{ 
    "query":"", 
        "filters": { 
            "mileage": {
                "from": 0, 
                "to": 40000
            }
      }
}

```

Is there something I'm missing? I'm referencing the following documentation.

> **[Filters | Swiftype Documentation](https://swiftype.com/documentation/app-search/api/search/filters#range-filters)**
>
> Learn how to get the most out of Swiftype

How I set up the index. I imported the documents first through the JSON API. I then set the field type for the mileage and some other fields from the app search UI. Do I need to re-import all my documents to get the field type to be indexed properly?

---

<div class="post-metadata">

**Author:** ![JasonStoltz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jasonstoltz/32/49893_2.png) [@JasonStoltz](https://discuss.elastic.co/u/JasonStoltz)\
**Post date:** [March 31, 2020, 12:11pm UTC](https://discuss.elastic.co/t/range-based-query-on-number-type/225763/2 "2020-03-31T12:11:47Z")

</div>

What you have looks correct. Are you using App Search at [swiftype.com](http://swiftype.com) or the self-managed version? If self-managed, what version are you using?

---

<div class="post-metadata">

**Author:** ![nathanwfish](https://avatars.discourse-cdn.com/v4/letter/n/8e7dd6/32.png) [@nathanwfish](https://discuss.elastic.co/u/nathanwfish)\
**Post date:** [March 31, 2020, 3:57pm UTC](https://discuss.elastic.co/t/range-based-query-on-number-type/225763/3 "2020-03-31T15:57:47Z")

</div>

@JasonStoltz Elastic App Search Version 7.6.1. This is Elastic App Search on [elastic.co](http://elastic.co).

---

<div class="post-metadata">

**Author:** ![nathanwfish](https://avatars.discourse-cdn.com/v4/letter/n/8e7dd6/32.png) [@nathanwfish](https://discuss.elastic.co/u/nathanwfish)\
**Post date:** [April 1, 2020, 10:50pm UTC](https://discuss.elastic.co/t/range-based-query-on-number-type/225763/4 "2020-04-01T22:50:34Z")

</div>

@JasonStoltz

Here's an example query and result set

```auto
    {
      "query": "",
       "filters": {
    	    	"year": {
    	    		"from": 2000,
    	    		"to": 2011
    	    	}
    	    
    	}
    } 

```

Here's the resulting response

```auto
{
    "meta": {
        "alerts": [],
        "warnings": [],
        "page": {
            "current": 1,
            "total_pages": 1,
            "total_results": 2,
            "size": 10
        },
        "engine": {
            "name": "test2",
            "type": "default"
        },
        "request_id": "a33f30a5-062f-4f09-817a-57f5318940c4"
    },
    "results": [
        {
            "standard_seating": {
                "raw": "5"
            },
            "to": {
                "raw": null
            },
            "fuel_capacity": {
                "raw": "16.50 gallons"
            },
            "driveline": {
                "raw": null
            },
            "latitude": {
                "raw": ""
            },
            "address": {
                "raw": ""
            },
            "_meta": {
                "id": "8436",
                "engine": "test2",
                "score": 1.0
            },
            "id": {
                "raw": "8436"
            },
            "images": {
                "raw": "[\"image-1.jpg\",\"image-2.jpg\",\"image-3.jpg\",\"image-4.jpg\",\"image-5.jpg\",\"image-6.jpg\",\"image-7.jpg\",\"image-8.jpg\",\"image-9.jpg\",\"image-10.jpg\",\"image-11.jpg\",\"image-12.jpg\",\"image-13.jpg\",\"image-14.jpg\",\"image-15.jpg\",\"image-16.jpg\",\"image-17.jpg\",\"image-18.jpg\",\"image-19.jpg\",\"image-20.jpg\",\"image-21.jpg\",\"image-22.jpg\",\"image-23.jpg\",\"image-24.jpg\",\"image-25.jpg\",\"image-26.jpg\",\"image-27.jpg\",\"image-28.jpg\",\"image-29.jpg\",\"image-30.jpg\",\"image-31.jpg\",\"image-32.jpg\",\"image-33.jpg\",\"image-34.jpg\",\"image-35.jpg\",\"image-36.jpg\",\"image-37.jpg\",\"image-38.jpg\",\"image-39.jpg\",\"image-40.jpg\",\"image-41.jpg\",\"image-42.jpg\",\"image-43.jpg\",\"image-44.jpg\",\"image-45.jpg\",\"image-46.jpg\",\"image-47.jpg\",\"image-48.jpg\"]"
            },
            "stock_number": {
                "raw": "2282D"
            },
            "careport": {
                "raw": ""
            },
            "dealer_id": {
                "raw": "20"
            },
            "state": {
                "raw": ""
            },
            "body_type": {
                "raw": "Sport Utility"
            },
            "vin": {
                "raw": "1FMKA99595"
            },
            "history": {
                "raw":""
            },
            "image_updated_at": {
                "raw": "2020-01-29T12:05:28+00:00"
            },
            "interior": {
                "raw": "Tan"
            },
            "fuel_type": {
                "raw": "Regular Unleaded"
            },
            "city": {
                "raw": ""
            },
            "make": {
                "raw": "Ford"
            },
            "model": {
                "raw": "Escape"
            },
            "brake_system": {
                "raw": "4-Wheel ABS"
            },
            "from": {
                "raw": "2020-01-28 12:06:29"
            },
            "vehicle_updated_at": {
                "raw": "2020-03-26T12:07:51+00:00"
            },
            "dealer": {
                "raw": ""
            },
            "longitude": {
                "raw": ""
            },
            "exterior_color": {
                "raw": "Gray"
            },
            "status_id": {
                "raw": "3"
            },
            "interior_color": {
                "raw": "Charcoal"
            },
            "phone": {
                "raw": ""
            },
            "style": {
                "raw": "No data"
            },
            "engine": {
                "raw": "4 Cylinder 2.5L"
            },
            "city_mileage": {
                "raw": "19 miles/gallon"
            },
            "status": {
                "raw": "CERTIFIED"
            },
            "trim": {
                "raw": "XLT"
            },
            "transmission": {
                "raw": null
            },
            "highway_mileage": {
                "raw": "25 miles/gallon"
            },
            "color": {
                "raw": "Charcoal"
            },
            "mileage": {
                "raw": 146651.0
            },
            "year": {
                "raw": 2009.0
            },
            "location": {
                "raw": ""
            },
            "price": {
                "raw": 4395.0
            },
            "zip": {
                "raw": ""
            }
        },
        {
            "standard_seating": {
                "raw": null
            },
            "to": {
                "raw": null
            },
            "fuel_capacity": {
                "raw": null
            },
            "driveline": {
                "raw": null
            },
            "latitude": {
                "raw": ""
            },
            "address": {
                "raw": ""
            },
            "_meta": {
                "id": "7371",
                "engine": "test2",
                "score": 1.0
            },
            "id": {
                "raw": "7371"
            },
            "images": {
                "raw": "[\"1601221197.jpg\",\"1601220984.jpg\",\"1601221188.jpg\",\"1601221172.jpg\",\"1601221147.jpg\",\"1601221012.jpg\",\"1601221108.jpg\",\"1601221110.jpg\",\"1601221208.jpg\",\"1601221130.jpg\",\"1601221168.jpg\",\"1601221122.jpg\",\"1601221169.jpg\"]"
            },
            "stock_number": {
                "raw": ""
            },
            "careport": {
                "raw": ""
            },
            "dealer_id": {
                "raw": "17"
            },
            "state": {
                "raw": ""
            },
            "body_type": {
                "raw": "4dr Car"
            },
            "vin": {
                "raw": "2T1C061034"
            },
            "history": {
                "raw": null
            },
            "image_updated_at": {
                "raw": "2020-02-26T22:23:21+00:00"
            },
            "interior": {
                "raw": "Gray"
            },
            "fuel_type": {
                "raw": null
            },
            "city": {
                "raw": ""
            },
            "make": {
                "raw": "Toyota"
            },
            "model": {
                "raw": "Corolla"
            },
            "brake_system": {
                "raw": null
            },
            "from": {
                "raw": "2019-12-24 08:11:22"
            },
            "vehicle_updated_at": {
                "raw": "2020-04-01T08:05:53+00:00"
            },
            "dealer": {
                "raw": ""
            },
            "longitude": {
                "raw": ""
            },
            "exterior_color": {
                "raw": "Blue"
            },
            "status_id": {
                "raw": "3"
            },
            "interior_color": {
                "raw": "Black"
            },
            "phone": {
                "raw": ""
            },
            "style": {
                "raw": null
            },
            "engine": {
                "raw": "4 Cylinder 1.8L"
            },
            "city_mileage": {
                "raw": null
            },
            "status": {
                "raw": "CERTIFIED"
            },
            "trim": {
                "raw": null
            },
            "transmission": {
                "raw": null
            },
            "highway_mileage": {
                "raw": null
            },
            "color": {
                "raw": "Blue"
            },
            "mileage": {
                "raw": 140594.0
            },
            "year": {
                "raw": 2014.0
            },
            "location": {
                "raw": ""
            },
            "price": {
                "raw": 8999.0
            },
            "zip": {
                "raw": ""
            }
        }
    ]
}

```

And here's a picture of the schema from the UI

 ![Screen Shot 2020-04-01 at 3.49.27 PM](https://us1.discourse-cdn.com/elastic/original/3X/3/b/3be6dd1d3f6ee0e98202d7b87143bb4a72080e70.png)

---

<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:** [April 29, 2020, 10:50pm UTC](https://discuss.elastic.co/t/range-based-query-on-number-type/225763/5 "2020-04-29T22:50:35Z")

</div>

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