I did some more investigation and it seems ES is treating my integer fields
as string fields and attempting string filter/comparison. e.g. this query
works fine -
curl -XGET 'http://localhost:920/twitter/audience/_search?pretty=true' -d '
{ query : { range : { followers_count : { from : 100, to : 50000 } } } }'
{
"took" : 12,
"timed_out" : false,
"_shards" : {
"total" : 5,
"successful" : 5,
"failed" : 0
},
"hits" : {
"total" : 1,
"max_score" : 1.0,
"hits" : [ {
"_index" : "twitter",
"_type" : "audience",
"_id" : "18142273",
"_score" : 1.0, "_source" :
{"twitter_id":"2953","screen_name":"Lamoureux71","name":"Charles
Lamoureux","location":"San Clemente CA","bio":"Married father of twins,
working in the automotive
industry.","followers_count":401,"friends_count":854,"statuses_count":836,"listed_count":12}
} ]
}
}
i am wondering where am i going wrong?
this is how i added the entry to ES -
IndexRequestBuilder irb = client.prepareIndex("twitter",
"audience", "18142273")
.setSource(jsonBuilder()
.startObject()
.field("twitter_id", "2953")
.field("screen_name", "Lamoureux71")
.field("name", "Charles Lamoureux")
.field("location", "San Clemente CA")
.field("bio", "Married father of twins, working in
the automotive industry.")
.field("followers_count", 401)
.field("friends_count", 854)
.field("statuses_count", 836)
.field("listed_count", 12)
.endObject()
)
.execute()
.actionGet();
thanks
On Sun, Feb 12, 2012 at 11:54 PM, T Vinod Gupta tvinod@readypulse.comwrote:
Hi,
I am a newbie to ES. Can someone tell, what i could be doing wrong in this
query -
curl -XGET 'http://localhost:920/twitter/_search?pretty=true' -d '
{
"fields" : ["name","screen_name","followers_count"],
"query" : {
"filtered" : {
"query" : { "matchAll" : {} },
"filter" : { "range" : {
"followers_count" : { "from" : 100, "to" : 10000 }
}
}
}
}
}'
{
"took" : 12,
"timed_out" : false,
"_shards" : {
"total" : 5,
"successful" : 5,
"failed" : 0
},
"hits" : {
"total" : 0,
"max_score" : null,
"hits" :
}
i have 2 elements in my index -
curl -XGET 'http://localhost:920/twitter/_search?pretty=true' -d '
{
"query" : { "matchAll" : {} } }'
{
"took" : 2,
"timed_out" : false,
"_shards" : {
"total" : 5,
"successful" : 5,
"failed" : 0
},
"hits" : {
"total" : 2,
"max_score" : 1.0,
"hits" : [ {
"_index" : "twitter",
"_type" : "user",
"_id" : "kimchy",
"_score" : 1.0, "_source" : { "name" : "Shay Banon" }
}, {
"_index" : "twitter",
"_type" : "audience",
"_id" : "18142273",
"_score" : 1.0, "_source" :
{"twitter_id":"2953","screen_name":"Lamoureux71","name":"Charles
Lamoureux","location":"San Clemente CA","bio":"Married father of twins,
working in the automotive
industry.","followers_count":401,"friends_count":854,"statuses_count":836,"listed_count":12}
} ]
}
}