From 743ec4346096fa6484142d6fe3d4386dd1545db9 Mon Sep 17 00:00:00 2001 From: Sarah Hoffmann Date: Thu, 14 Jun 2018 00:11:19 +0200 Subject: [PATCH] nearest place search should match any of given tokens not all When multiple isin tokens are given, then these are duplicates and it is enough that any one of them is found in the name_vector. Fixes #1056. --- sql/partition-functions.src.sql | 4 ++-- test/bdd/db/import/parenting.feature | 19 +++++++++++++++++++ 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/sql/partition-functions.src.sql b/sql/partition-functions.src.sql index cc11cf96..9ae020e4 100644 --- a/sql/partition-functions.src.sql +++ b/sql/partition-functions.src.sql @@ -96,7 +96,7 @@ BEGIN SELECT place_id, name_vector, address_rank, search_rank, ST_Distance(centroid, point) as distance, null as isguess FROM search_name_-partition- - WHERE name_vector @> isin_token + WHERE name_vector && isin_token AND ST_DWithin(centroid, point, 0.015) AND search_rank between 26 and 27 ORDER BY distance ASC limit 1 @@ -124,7 +124,7 @@ BEGIN SELECT place_id, name_vector, address_rank, search_rank, ST_Distance(centroid, point) as distance, null as isguess FROM search_name_-partition- - WHERE name_vector @> isin_token + WHERE name_vector && isin_token AND ST_DWithin(centroid, point, 0.03) AND search_rank between 16 and 22 ORDER BY distance ASC limit 1 diff --git a/test/bdd/db/import/parenting.feature b/test/bdd/db/import/parenting.feature index 87467fd2..a3648539 100644 --- a/test/bdd/db/import/parenting.feature +++ b/test/bdd/db/import/parenting.feature @@ -441,3 +441,22 @@ Feature: Parenting of objects | object | parent_place_id | | N1 | W2 | + # github #1056 + Scenario: Full names should be preferably matched for nearest road + Given the grid + | 1 | | 2 | 5 | + | | | | | + | 3 | | | 4 | + | | 10| | | + And the places + | osm | class | type | name+name | geometry | + | W1 | highway | residential | Via Cavassico superiore | 1, 2 | + | W3 | highway | residential | Via Cavassico superiore | 2, 5 | + | W2 | highway | primary | Via Frazione Cavassico | 3, 4 | + And the named places + | osm | class | type | addr+street | + | N10 | shop | yes | Via Cavassico superiore | + When importing + Then placex contains + | object | parent_place_id | + | N10 | W1 | -- 2.39.5