Last active
June 9, 2017 13:22
-
-
Save pka/f6bb2fadaa48ae9e259b59e173c88ce2 to your computer and use it in GitHub Desktop.
Quickfinder adress search example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE MATERIALIZED VIEW av.adressen AS | |
SELECT hau.pk, lok.r1_text || COALESCE(' ' || hau.r1_hausnum, '') AS adresse, hau.wkb_geometry | |
FROM av.ge_hausnummerpos hau | |
JOIN av.ge_lokalisationsnamepos lok ON lok.r1_benannt=hau.r1_gebaeud; | |
CREATE INDEX adressen_trgm_idx ON av.adressen USING gin (adresse gin_trgm_ops); | |
SELECT adresse,ST_AsBinary(wkb_geometry)::geometry | |
FROM av.adressen | |
WHERE similarity(adresse, %(search)s) > 0.2 | |
ORDER BY adresse <-> %(search)s | |
LIMIT %(limit)s |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment