Numeric field filter not working

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"
{
"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.
For more options, visit https://groups.google.com/groups/opt_out.

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 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
"
{
"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.
For more options, visit 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.
For more options, visit https://groups.google.com/groups/opt_out.