Slide 1

Slide 1 text

Searching OpenStreetMap with Elasticsearch photon.komoot.de Christoph Lingg – [email protected]

Slide 2

Slide 2 text

komoot

Slide 3

Slide 3 text

OpenStreetMap ● free ● editable map ● worldwide ● built by volunteers ● open-content licence

Slide 4

Slide 4 text

OpenStreetMap

Slide 5

Slide 5 text

OpenStreetMap

Slide 6

Slide 6 text

Geocoding „Böcklerpark“ Coordinate(10.1 50.2) Park Kreuzberg, Berlin, Germany

Slide 7

Slide 7 text

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

Slide 8

Slide 8 text

Closing the Gap ● suitable for mobile usage ● “built on the shoulder of a giant” → elasticsearch ● open source ● free public API ● enhance the OSM ecosystem

Slide 9

Slide 9 text

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

Slide 10

Slide 10 text

Photon Importer VIASKO Bahnhofstraße Postcode 10403 City Berlin State Country Germany Berlin Nominatim DB Postgis Elasticsearch Index Photon Importer

Slide 11

Slide 11 text

Type-ahead search "filter": { "photonngram": { "min_gram": "1", "type": "edgeNGram", "max_gram": "100" },... }

Slide 12

Slide 12 text

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" } } } }

Slide 13

Slide 13 text

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}" } } } ]

Slide 14

Slide 14 text

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]

Slide 15

Slide 15 text

komoot.de/hack15