Oct 10, 2018
0
Level 8
How to get result in scout/ElasticSearch with distance filter ?
hello , I work with Scout /Elasticsearch and this script works fine :
return search_index::search('*')
->from(0)
->take(50)
->get();
now I would like to get results less than 10KM from this point ['lat' => 35.5, 'lon' => -2.6], every indexed document is located with :
...
"station_location": {
"type": "geo_point"
},
...
here my Elastic search index
{
"stations_search_engine": {
"mappings": {
"search_indices": {
"properties": {
"company_id": {
"type": "text",
"fields": {
"raw": {
"type": "keyword"
}
}
},
"company_label": {
"type": "text",
"fields": {
"raw": {
"type": "keyword"
}
}
},
"company_name": {
"type": "text",
"fields": {
"raw": {
"type": "keyword"
}
}
},
"id": {
"type": "long"
},
"line_id": {
"type": "text",
"fields": {
"raw": {
"type": "keyword"
}
}
},
"line_label": {
"type": "text",
"fields": {
"raw": {
"type": "keyword"
}
}
},
"line_name": {
"type": "text",
"fields": {
"raw": {
"type": "keyword"
}
}
},
"line_number": {
"type": "text",
"fields": {
"raw": {
"type": "keyword"
}
}
},
"line_url": {
"type": "text",
"fields": {
"raw": {
"type": "keyword"
}
}
},
"station_address": {
"type": "text",
"fields": {
"raw": {
"type": "keyword"
}
}
},
"station_label": {
"type": "text",
"fields": {
"raw": {
"type": "keyword"
}
}
},
"station_location": {
"type": "geo_point"
},
"station_name": {
"type": "text",
"fields": {
"raw": {
"type": "keyword"
}
}
}
}
}
}
}
}
Please or to participate in this conversation.