Sorry for the long delay, was out of town.
I re-inserted objects and am getting similarly strange results, but in
a different field this time.
I used the rubberband gem to create the objects:
100.times {
obj = { "name" => "test", "rating_int" => (rand50).to_i,
"my_point" => { "lat" => 30+20rand/10.0, "lon" => 20+20*rand/
10.0 } }
client.index(obj)
}
This query ran fine this time:
curl -XGET 'http://localhost:9200/twitter/test/_search' -d '
{
"fields" : ["my_point"],
"size" : 10,
"query" : {
"filtered" : {
"query" : {
"query_string" : { "query" : "name:test" }
},
"filter" : {
"range" : { "rating_int" : { "from": 10, "to" :20 } }
}
}
},
"sort" : [
{
"_geo_distance" : {
"my_point" : "30,20",
"order" : "asc"
}
},
"_score"
]
}'
However, if I add the rating_int field this time, I again see strange
results:
curl -XGET 'http://localhost:9200/twitter/test/_search?pretty=true' -d
'
{
"fields" : ["my_point", "rating_int"],
"size" : 10,
"query" : {
"filtered" : {
"query" : {
"query_string" : { "query" : "name:test" }
},
"filter" : {
"range" : { "rating_int" : { "from": 10, "to" :20 } }
}
}
},
"sort" : [
{
"_geo_distance" : {
"my_point" : "30,20",
"order" : "asc"
}
},
"_score"
]
}'
Results:
{
"took" : 293,
"timed_out" : false,
"_shards" : {
"total" : 5,
"successful" : 5,
"failed" : 0
},
"hits" : {
"total" : 19,
"max_score" : null,
"hits" : [ {
"_index" : "twitter",
"_type" : "test",
"_id" : "aEKDbdjBTh-E_quJz3_o1Q",
"_score" : 3.368767,
"fields" : {
"rating_int" : "AAAADg==",
"my_point" : "30.617616303438,20.6218944909627"
},
"sort" : [ 91.09867513372355, 3.368767 ]
},
{
"_index" : "twitter",
"_type" : "test",
"_id" : "ALo0MEo8TuGm8lQKCeo5Dg",
"_score" : 3.3067431,
"fields" : {
"rating_int" : "AAAAEg==",
"my_point" : "30.89625050032,20.1114635818668"
},
"sort" : [ 100.34228308708265, 3.3067431 ]
},
... ] }
When I do a GET on that id, though, everything looks fine:
curl -XGET 'http://localhost:9200/twitter/test/aEKDbdjBTh-E_quJz3_o1Q?
pretty=true'
{
"_index" : "twitter",
"_type" : "test",
"_id" : "aEKDbdjBTh-E_quJz3_o1Q",
"_version" : 1,
"exists" : true, "_source" : {"my_point":{"lon":
20.6218944909627,"lat":30.617616303438},"name":"test","rating_int":14}
}
From the original results and now these, my first reaction is that it
might be returning internal values from sorting?
On Aug 11, 4:36 pm, Shay Banon kim...@gmail.com wrote:
Can you post a curl recreation including sample indexing of data? Thats
strange that you get that...
On Thu, Aug 11, 2011 at 10:04 PM, rfq riot.i...@gmail.com wrote:
I had a quick question on results from a particular query.
Right now we just have a bunch of test documents with a field:
"my_point" : {
"lat" : #,
"lon" : #
}
where lat is between 30 and 32, and lon is between 20 and 22 (again,
just for testing, really).
Here's the query (without "fields" set):
{
"size" : 10,
"query" : {
"query_string" : { "query" : "name:test" }
}
},
"sort" : [
{
"_geo_distance" : {
"my_point" : "30,20",
"order" : "asc"
}
},
"_score"
]
}
The objects I get back look fine:
{... _source:
{ "my_point":"lon21.3106349430918lat31.0521010454204", ... } ...}
However, if I limit the fields that are returned (adding "fields" :
["my_point"] to the query), the returned value of "my_point" changes:
{... "fields":
{"my_point":"-89.99703053788122,-171.20920843765003" } ... }
I figure I'm just missing something simple, but thought I'd ask. Where
is the second value coming from?
Thanks,