Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Searching OpenStreetMap with Elasticsearch

Searching OpenStreetMap with Elasticsearch

Christoph Lingg

November 24, 2015
Tweet

Other Decks in Programming

Transcript

  1. Nominatim • started many years ago • standard solution for

    OSM • based on Postgres/Postgis, SQL, PHP, C • powerfull + mature • drawbacks ◦ slow ◦ no typo tolerance ◦ no partial match / search-as-you-type
  2. Closing the Gap • suitable for mobile usage • “built

    on the shoulder of a giant” → elasticsearch • open source • free public API • enhance the OSM ecosystem
  3. { "name": "VIASKO", "housenumber": "33a", "amenity": "restaurant", "coordinate": [10, 52

    ], "street": "Bahnhofstraße", "postcode": "10403", "city": "Berlin", "state": "Berlin", "country": "Germany", "context": "Kreuzberg", "importance": 0.1 } OSM Entry { "name": "VIASKO", "housenumber": "33a", "amenity": "restaurant", "coordinate": [10, 52] } Photon Document
  4. Photon Importer VIASKO Bahnhofstraße Postcode 10403 City Berlin State Country

    Germany Berlin Nominatim DB Postgis Elasticsearch Index Photon Importer
  5. Typo Tolerance "query": { "bool": { "must": { "match": {

    "collector.default": { "fuzziness": 1, "query": "${query}", "analyzer": "search_ngram", "prefix_length": 2 } } }, "should":{ "match": { "collector.${lang}.raw": { "query": "${query}", "boost": 100, "analyzer": "search_raw" } } } }
  6. Location biased "score_mode": "multiply", "functions": [ { "script_score": { "script":

    "1 + doc['importance'].value * 100" } }, { "script_score": { "script": " dist = doc['coordinate'].distanceInKm(lat, lon); 0.5 + ( 1.5 / (1.0 + dist/40.0) )", "params": { "lat": "${lat}", "lon": "${lon}" } } } ]
  7. Photon Project • 100 Mio documents • 60 GB search

    index • easy install • photon.komoot.de • github.com/komoot/photon • want be informed for the next sprint? → [email protected]