Context suggester geo


(fares oueslati) #1

Hello,

I m using Elasticsearch 2.2.0.

Trying to make a google like address completion.

I'm using Logstash 2.2 to index addresses in ES with a completion field named suggest with a geo context field pin. Here's the mappings in my index template.

..."properties": {
"lonlat":{
"properties":{
"location": {
"type": "geo_point"
}}},
"suggest" : { "type": "completion",
"context":{
"pin": { "type":"geo", "precision":["1km","5m"], "neighbors":true,
"path":"location",
"default":{"lat":0.0,"lon":0.0}
}
},
"payloads" : true,
"analyzer" : "custom_index_analyzer",
"search_analyzer": "custom_search_analyzer" },...

When I try completion suggester without context it works well, but when I add the geo context field named "pin" in the mapping properties i don't have any result.

Here's the related parts of my logstash config :

    ...csv {columns => ["ID","numero","voie","code_postal","nom_commune","source","latitude","longitude"] separator => ","}
    if [latitude] and [longitude] {
        # move into own location object for additional geo_point type in ES
        # copy field, then merge to create array for bettermap
        mutate {
          rename => [ "latitude", "[location][lat]", "longitude", "[location][lon]" ]
          add_field => { "lonlat" => [ "%{[location][lat]}", "%{[location][lon]}" ] }
        }
      }...
       mutate {convert => [ "[location][lat]", "float" ]
                      convert => [ "[location][lon]", "float" ]
       }...

Then here is my query :

POST http://@:9200/index/_suggest/
{
"suggest" : {
"text" : "16 ",
"completion" : {
"field" : "suggest",
"size": 10,
"context": {
"pin":{"lon":2.29,"lat":48.75}
}
}
}
}

When I put lon:0 and lat:0 it works but it doenst filter the results.

Any help please to make it consider the geo context ? Thanks


(system) #2