i solved it myself. I needed to set slug in my mappings to "not_analyzed" and i change the query to this one:
{ "from": 0, "size": 3, "query": { "filtered": { "query": { "bool": { "must_not": [ { "match": { "slug": "adlon-hotel" } } ] } }, "filter": { "exists": { "field": "pin" } } } }, "sort": [ { "_geo_distance": { "pin": { "lat": 52.51515, "lon": 13.38019 }, "order": "asc", "unit": "km", "distance_type": "arc" } } ] } Am Dienstag, 14. Oktober 2014 10:04:00 UTC+2 schrieb Sören Martius: > > Hello, > > In my Index i have several locations with some information and geo data. > In the detail view of an location i try to query for locations which are > near by the current one. > I am confused, cause my query does not return the correct order of > locations. If you check the geo locations you will see, that the order is > wrong. > The bool query is there for preventing getting the current location in the > result ( identified by the locations slug ). > > In the following example, please notice that the query is run with the geo > point of "adlon hotel", so the first returned location should be "Hotel > Prens Berlin Kreuzberg". > > Here is the query: > > curl -XGET 'http://localhost:9200/search/location/_search' -d > '{"sort":[{"_geo_distance":{"pin":[52.51515,13.38019],"order":"asc","unit":"km","distance_type":"arc"}}],"query":{"bool":{"must_not":[{"match":{"slug":"adlon-hotel"}}]}},"size":3}' > > > Here is my mapping: > > > > > > > > > > { > > "search" : { > > "mappings" : { > > "location" : { > > "_meta" : { > > "model" : > "AnchorVentures\\Bundle\\LocationBundle\\Entity\\Location" > > }, > > "_all" : { > > "auto_boost" : true > > }, > > "properties" : { > > "address" : { > > "properties" : { > > "pin" : { > > "type" : "geo_point", > > "store" : true, > > "lat_lon" : true > > }, > > "zipcode" : { > > "type" : "string", > > "store" : true > > } > > } > > }, > > "city" : { > > "type" : "nested", > > "properties" : { > > "name" : { > > "type" : "string", > > "boost" : 10.0, > > "store" : true > > } > > } > > }, > > "countedRatings" : { > > "type" : "string", > > "store" : true > > }, > > "createdAt" : { > > "type" : "string", > > "store" : true > > }, > > "details" : { > > "type" : "nested", > > "properties" : { > > "guestsQuantity" : { > > "type" : "string", > > "store" : true > > }, > > "isCatering" : { > > "type" : "string", > > "store" : true > > }, > > "isIndoor" : { > > "type" : "string", > > "store" : true > > }, > > "isOutdoor" : { > > "type" : "string", > > "store" : true > > }, > > "isOvernightAccommodation" : { > > "type" : "string", > > "store" : true > > }, > > "price" : { > > "type" : "string", > > "store" : true > > }, > > "roomQuantity" : { > > "type" : "string", > > "store" : true > > } > > } > > }, > > "name" : { > > "type" : "string", > > "store" : true > > }, > > "slug" : { > > "type" : "string", > > "store" : true > > }, > > "updatedAt" : { > <span style="color: > ... -- 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+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/1438f59c-e889-42b3-ab98-274a0c7b4d48%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.