BoundingBox Query working with GET-Parameter but not with GET Body


(Jan Ramm) #1

Hi all,

i've got a problem with a BoudingBox Query.
When i do a search and send the query via get parameter everything works
fine.
If i do it via a request body i don't get a hit.

Can you give me a hint what im doing wrong?

If i do a Boundingbox query with a get body i get no result.

If i do the same query with a get param i will get the expected result.

What is my fault?

Create Index + Mapping

curl -XPOST localhost:9200/testpois5 -d '{
"settings" : {
"number_of_shards" : 1
},
"mappings" : {
"driver" : {
"properties" : {
"location" : { "type" : "geo_point" }
}
}
}
}'

Create one driver

curl -XPUT http://localhost:9200/testpois5/driver/1 -d '{"location":{"lat":53, "lon":9}}}'

#do a search request with request Body
curl -XGET 'http://localhost:9200/testpois5/driver/_search?pretty=true' -d '{"query":{"match_all":{}},"filter":{"geo_bbox":{"location":{"top_left":[9.935735,53.552467],"bottom_right":[10.0,52.551963]}}}}'

Result

> {

"took" : 0,

"timed_out" : false,

"_shards" : {

"total" : 1,

"successful" : 1,

"failed" : 0

},

"hits" : {

"total" : 0,

"max_score" : null,

"hits" : [ ]

}

#}

No Match found? This should match, where is the Problem?

Do a search request with get param

URL Decoded http://localhost:9200/testpois5/driver/_search?{"query":{"match_all":{}},"filter":{"geo_bbox":{"location":{"top_left":[9.935735,53.552467],"bottom_right":[10.0,52.551963]}}}}

curl -XGET 'http://localhost:9200/testpois5/driver/_search?{"query"%3A{"match_all"%3A{}}%2C"filter"%3A{"geo_bbox"%3A{"location"%3A{"top_left"%3A[9.935735%2C53.552467]%2C"bottom_right"%3A[10.0%2C52.551963]}}}}'

Result:

{"took":1,"timed_out":false,"_shards":{"total":1,"successful":1,"failed":0},"hits":{"total":1,"max_score":1.0,"hits":[{"_index":"testpois5","_type":"driver","_id":"1","_score":1.0, "_source" : {"location":{"lat":53, "lon":9}}}}]}}

Match found everything works as expected

Link to gist: https://gist.github.com/janramm87/7464990

--
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.


(Alexander Reelsen) #2

Hey,

had a quick peek on your sample, my assumption is the following:

  • The query itself does not return any hits, because the longitude of the
    POI is outside the bounding box
  • The reason why your second query does return something is, that actually
    a match_all query is executed, because you didnt specify a query. If you
    wanted to specify it, you would have to put the encoded body into the
    source parameter.

The correct call would be curl -XGET '
http://localhost:9200/testpois5/driver/_search?source=ENCODING_PARTY_HERE...

Hope this helps.

--Alex

On Thu, Nov 14, 2013 at 12:16 PM, Jan Ramm j.ramm@mytaxi.net wrote:

Hi all,

i've got a problem with a BoudingBox Query.
When i do a search and send the query via get parameter everything works
fine.
If i do it via a request body i don't get a hit.

Can you give me a hint what im doing wrong?

If i do a Boundingbox query with a get body i get no result.

If i do the same query with a get param i will get the expected result.

What is my fault?

Create Index + Mapping

curl -XPOST localhost:9200/testpois5 -d '{
"settings" : {
"number_of_shards" : 1
},
"mappings" : {
"driver" : {
"properties" : {
"location" : { "type" : "geo_point" }
}
}
}
}'

Create one driver

curl -XPUT http://localhost:9200/testpois5/driver/1 -d '{"location":{"lat":53, "lon":9}}}'

#do a search request with request Body
curl -XGET 'http://localhost:9200/testpois5/driver/_search?pretty=true' -d '{"query":{"match_all":{}},"filter":{"geo_bbox":{"location":{"top_left":[9.935735,53.552467],"bottom_right":[10.0,52.551963]}}}}'

Result

> {

"took" : 0,

"timed_out" : false,

"_shards" : {

"total" : 1,

"successful" : 1,

"failed" : 0

},

"hits" : {

"total" : 0,

"max_score" : null,

"hits" : [ ]

}

#}

No Match found? This should match, where is the Problem?

Do a search request with get param

URL Decoded http://localhost:9200/testpois5/driver/_search?{"query":{"match_all":{}},"filter":{"geo_bbox":{"location":{"top_left":[9.935735,53.552467],"bottom_right":[10.0,52.551963]}}}}

curl -XGET 'http://localhost:9200/testpois5/driver/_search?{"query"%3A{"match_all"%3A{}}%2C"filter"%3A{"geo_bbox"%3A{"location"%3A{"top_left"%3A[9.935735%2C53.552467]%2C"bottom_right"%3A[10.0%2C52.551963]}}}}'

Result:

{"took":1,"timed_out":false,"_shards":{"total":1,"successful":1,"failed":0},"hits":{"total":1,"max_score":1.0,"hits":[{"_index":"testpois5","_type":"driver","_id":"1","_score":1.0, "_source" : {"location":{"lat":53, "lon":9}}}}]}}

Match found everything works as expected

Link to gist: https://gist.github.com/janramm87/7464990

--
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.


(system) #3