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" : {

            "type" : "string",

            "store" : true

          }

        }

      }

    }

  }

}


And finally some documents









{

  "took" : 2,

  "timed_out" : false,

  "_shards" : {

    "total" : 5,

    "successful" : 5,

    "failed" : 0

  },

  "hits" : {

    "total" : 10,

    "max_score" : 1.0,

    "hits" : [ {

      "_index" : "search",

      "_type" : "location",

      "_id" : "207",

      "_score" : 1.0,

      "_source":{"name":"Badeschiff","slug":"badeschiff","countedRatings":0,
"createdAt":"2014-10-13T10:40:58+02:00","updatedAt":
"2014-10-13T10:40:58+02:00","details":{"price":1,"isIndoor":true,"isOutdoor"
:true,"isCatering":true,"isOvernightAccommodation":false,"roomQuantity":1,
"guestsQuantity":50},"city":{"name":"Berlin"},"address":{"zipcode":"12435",
"pin":"52.4970479,13.4525442"}}

    }, {

      "_index" : "search",

      "_type" : "location",

      "_id" : "214",

      "_score" : 1.0,

      "_source":{"name":"Le Plat du Jour","slug":"le-plat-du-jour",
"countedRatings":0,"createdAt":"2014-10-13T10:40:58+02:00","updatedAt":
"2014-10-13T10:40:58+02:00","details":{"price":5,"isIndoor":true,"isOutdoor"
:true,"isCatering":true,"isOvernightAccommodation":false,"roomQuantity":4,
"guestsQuantity":50},"city":{"name":"Hamburg"},"address":{"zipcode":"20095",
"pin":"53.54911,9.99439"}}

    }, {

      "_index" : "search",

      "_type" : "location",

      "_id" : "206",

      "_score" : 1.0,

      "_source":{"name":"Spreequartier","slug":"spreequartier",
"countedRatings":0,"createdAt":"2014-10-13T10:40:58+02:00","updatedAt":
"2014-10-13T10:40:58+02:00","details":{"price":5,"isIndoor":true,"isOutdoor"
:true,"isCatering":true,"isOvernightAccommodation":false,"roomQuantity":3,
"guestsQuantity":80},"city":{"name":"Berlin"},"address":{"zipcode":"10245",
"pin":"52.5018737,13.4484104"}}

    }, {

      "_index" : "search",

      "_type" : "location",

      "_id" : "213",

      "_score" : 1.0,

      "_source":{"name":"Club Heim im Schanzenpark","slug":
"club-heim-im-schanzenpark","countedRatings":1,"createdAt":
"2014-10-13T10:40:58+02:00","updatedAt":"2014-10-13T10:40:58+02:00",
"details":{"price":5,"isIndoor":true,"isOutdoor":true,"isCatering":true,
"isOvernightAccommodation":false,"roomQuantity":4,"guestsQuantity":150},
"city":{"name":"Hamburg"},"address":{"zipcode":"20357","pin":
"53.56473,9.97387"}}

    }, {

      "_index" : "search",

      "_type" : "location",

      "_id" : "209",

      "_score" : 1.0,

      "_source":{"name":"Hotel Prens Berlin Kreuzberg","slug":
"hotel-prens-berlin-kreuzberg","countedRatings":0,"createdAt":
"2014-10-13T10:40:58+02:00","updatedAt":"2014-10-13T10:40:58+02:00",
"details":{"price":4,"isIndoor":true,"isOutdoor":true,"isCatering":true,
"isOvernightAccommodation":false,"roomQuantity":50,"guestsQuantity":500},
"city":{"name":"Berlin"},"address":{"zipcode":"10967","pin":
"52.49517,13.42109"}}

    }, {

      "_index" : "search",

      "_type" : "location",

      "_id" : "211",

      "_score" : 1.0,

      "_source":{"name":"Bahrenfelder Trabrennbahn","slug":
"bahrenfelder-trabrennbahn","countedRatings":1,"createdAt":
"2014-10-13T10:40:58+02:00","updatedAt":"2014-10-13T10:40:58+02:00",
"details":{"price":2,"isIndoor":true,"isOutdoor":false,"isCatering":true,
"isOvernightAccommodation":false,"roomQuantity":1,"guestsQuantity":300},
"city":{"name":"Hamburg"},"address":{"zipcode":"22761","pin":
"53.57829,9.89291"}}

    }, {

      "_index" : "search",

      "_type" : "location",

      "_id" : "208",

      "_score" : 1.0,

      "_source":{"name":"Die Fabrik","slug":"die-fabrik","countedRatings":0,
"createdAt":"2014-10-13T10:40:58+02:00","updatedAt":
"2014-10-13T10:40:58+02:00","details":{"price":4,"isIndoor":true,"isOutdoor"
:true,"isCatering":true,"isOvernightAccommodation":false,"roomQuantity":20,
"guestsQuantity":250},"city":{"name":"Berlin"},"address":{"zipcode":"10997",
"pin":"52.49875,13.44583"}}

    }, {

      "_index" : "search",

      "_type" : "location",

      "_id" : "210",

      "_score" : 1.0,

      "_source":{"name":"Ivbergs Hotel Charlottenburg","slug":
"ivbergs-hotel-charlottenburg","countedRatings":0,"createdAt":
"2014-10-13T10:40:58+02:00","updatedAt":"2014-10-13T10:40:58+02:00",
"details":{"price":3,"isIndoor":true,"isOutdoor":true,"isCatering":true,
"isOvernightAccommodation":false,"roomQuantity":35,"guestsQuantity":150},
"city":{"name":"Berlin"},"address":{"zipcode":"14057","pin":
"52.507,13.29408"}}

    }, {

      "_index" : "search",

      "_type" : "location",

      "_id" : "205",

      "_score" : 1.0,

      "_source":{"name":"Adlon Hotel","slug":"adlon-hotel","countedRatings":
4,"createdAt":"2014-10-13T10:40:58+02:00","updatedAt":
"2014-10-13T10:40:58+02:00","details":{"price":2,"isIndoor":true,"isOutdoor"
:false,"isCatering":true,"isOvernightAccommodation":true,"roomQuantity":4,
"guestsQuantity":150},"city":{"name":"Berlin"},"address":{"zipcode":"10117",
"pin":"52.51515,13.38019"}}

    }, {

      "_index" : "search",

      "_type" : "location",

      "_id" : "212",

      "_score" : 1.0,

      "_source":{"name":"Astrabar","slug":"astrabar","countedRatings":0,
"createdAt":"2014-10-13T10:40:58+02:00","updatedAt":
"2014-10-13T10:40:58+02:00","details":{"price":1,"isIndoor":true,"isOutdoor"
:false,"isCatering":true,"isOvernightAccommodation":false,"roomQuantity":1,
"guestsQuantity":50},"city":{"name":"Hamburg"},"address":{"zipcode":"20359",
"pin":"53.5488403,9.9607657"}}

    } ]

  }

}



-- 
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/elasticsearch/a20a6cbc-5b1b-4696-aa0b-17adca4c36ba%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to