# Numeric field filter not working

**URL:** <https://discuss.elastic.co/t/numeric-field-filter-not-working/12122>\
**Category:** Elasticsearch\
**Created:** [May 25, 2013, 8:50pm UTC](https://discuss.elastic.co/t/numeric-field-filter-not-working/12122 "2013-05-25T20:50:36Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Deep\_2](https://avatars.discourse-cdn.com/v4/letter/d/7feea3/32.png) [@Deep\_2](https://discuss.elastic.co/u/Deep_2)\
**Post date:** [May 25, 2013, 8:50pm UTC](https://discuss.elastic.co/t/numeric-field-filter-not-working/12122/1 "2013-05-25T20:50:36Z")

</div>

I have create a parent child schema. I have a numeric field (budget) in my  
parent. I want to return results only if the numeric fields is \> 0. But  
this query does not seem to work.

I have written the following query:

{  
"size" : 20,  
"query" : {  
"has\_parent" : {  
"parent\_type" : "adgroup",  
"query" : {  
"bool" : {  
"must" : [  
{"term" : { "active" : true}},  
{"term" : { "kwtargeting" : "shipping"}},  
{"term" : { "publisher.name" : "metro411"}},  
{"range" : {  
"publisher.budget" : { "gt" : 101 }  
}  
}  
]  
}  
}  
}  
},  
"filter" : {  
"geo\_distance" : {  
"geolocation" : {  
"lat":"40.67933","lon":"-75.38082"  
},  
"distance" : "30mi"  
}  
},  
"sort" : [{  
"\_geo\_distance" : {  
"geolocation" : {  
"lat":"40.67933","lon":"-75.38082"  
},  
"unit" : "mi"  
}  
}  
]  
}

My data in the parent index is:

curl -XPOST "[http://localhost:9200/ads/adgroup/\_search?pretty&explain=true](http://localhost:9200/ads/adgroup/_search?pretty&explain=true)"  
{  
"took" : 1,  
"timed\_out" : false,  
"\_shards" : {  
"total" : 5,  
"successful" : 5,  
"failed" : 0  
},  
"hits" : {  
"total" : 1,  
"max\_score" : 1.0,  
"hits" : [ {  
"\_shard" : 2,  
"\_node" : "PpSEQU2FQJKfWRSLiXTD7Q",  
"\_index" : "ads",  
"\_type" : "adgroup",  
"\_id" : "1",  
"\_score" : 1.0, "\_source" : {"name":"FedEx", "caption" : "We deliver  
on time", "adtype" : "cpm", "active": true, "kwtargeting" :  
["Shipping","Courier"], "publisher" : [ {"name" : "Metro411", "bid":0.15,  
"budget": "250.00"},{"name" : "Cricket", "bid":0.3, "budget": "100.00"}] },  
"\_explanation" : {  
"value" : 1.0,  
"description" : "ConstantScore(cache(\_type:adgroup)), product of:",  
"details" : [ {  
"value" : 1.0,  
"description" : "boost"  
}, {  
"value" : 1.0,  
"description" : "queryNorm"  
} ]  
}  
} ]  
}  
}

Help would on the same is appreciated.  
Regards,

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![Ivan](https://avatars.discourse-cdn.com/v4/letter/i/df788c/32.png) [@Ivan](https://discuss.elastic.co/u/Ivan)\
**Post date:** [May 26, 2013, 2:49pm UTC](https://discuss.elastic.co/t/numeric-field-filter-not-working/12122/2 "2013-05-26T14:49:34Z")

</div>

Judging by your sample document, the budget field is mapped as a string.  
Can you provide your mapping? Try explicitly providing a mapping for your  
index with that field set as a numeric type.

Ivan  
On May 25, 2013 1:50 PM, "Deep" [ishwardeep@gmail.com](mailto:ishwardeep@gmail.com) wrote:

> I have create a parent child schema. I have a numeric field (budget) in my  
> parent. I want to return results only if the numeric fields is \> 0. But  
> this query does not seem to work.
> 
> I have written the following query:
> 
> {  
> "size" : 20,  
> "query" : {  
> "has\_parent" : {  
> "parent\_type" : "adgroup",  
> "query" : {  
> "bool" : {  
> "must" : [  
> {"term" : { "active" : true}},  
> {"term" : { "kwtargeting" : "shipping"}},  
> {"term" : { "publisher.name" : "metro411"}},  
> {"range" : {  
> "publisher.budget" : { "gt" : 101 }  
> }  
> }  
> ]  
> }  
> }  
> }  
> },  
> "filter" : {  
> "geo\_distance" : {  
> "geolocation" : {  
> "lat":"40.67933","lon":"-75.38082"  
> },  
> "distance" : "30mi"  
> }  
> },  
> "sort" : [{  
> "\_geo\_distance" : {  
> "geolocation" : {  
> "lat":"40.67933","lon":"-75.38082"  
> },  
> "unit" : "mi"  
> }  
> }  
> ]  
> }
> 
> My data in the parent index is:
> 
> curl -XPOST "[http://localhost:9200/ads/adgroup/\_search?pretty&explain=true](http://localhost:9200/ads/adgroup/_search?pretty&explain=true)  
> "  
> {  
> "took" : 1,  
> "timed\_out" : false,  
> "\_shards" : {  
> "total" : 5,  
> "successful" : 5,  
> "failed" : 0  
> },  
> "hits" : {  
> "total" : 1,  
> "max\_score" : 1.0,  
> "hits" : [ {  
> "\_shard" : 2,  
> "\_node" : "PpSEQU2FQJKfWRSLiXTD7Q",  
> "\_index" : "ads",  
> "\_type" : "adgroup",  
> "\_id" : "1",  
> "\_score" : 1.0, "\_source" : {"name":"FedEx", "caption" : "We deliver  
> on time", "adtype" : "cpm", "active": true, "kwtargeting" :  
> ["Shipping","Courier"], "publisher" : [ {"name" : "Metro411", "bid":0.15,  
> "budget": "250.00"},{"name" : "Cricket", "bid":0.3, "budget": "100.00"}] },  
> "\_explanation" : {  
> "value" : 1.0,  
> "description" : "ConstantScore(cache(\_type:adgroup)), product of:",  
> "details" : [ {  
> "value" : 1.0,  
> "description" : "boost"  
> }, {  
> "value" : 1.0,  
> "description" : "queryNorm"  
> } ]  
> }  
> } ]  
> }  
> }
> 
> Help would on the same is appreciated.  
> Regards,
> 
> --  
> You received this message because you are subscribed to the Google Groups  
> "elasticsearch" group.  
> To unsubscribe from this group and stop receiving emails from it, send an  
> email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<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 6, 2017, 2:34am UTC](https://discuss.elastic.co/t/numeric-field-filter-not-working/12122/3 "2017-07-06T02:34:44Z")

</div>


