From 98c2e08add81579abe36519e7bb62077800c6b8a Mon Sep 17 00:00:00 2001 From: Sarah Hoffmann Date: Thu, 2 Sep 2021 18:13:45 +0200 Subject: [PATCH] reduce penalty for special searches by name Additional penalty for special terms with operator None should only go to near searches. To reduce the number of produced searches, restrict the none operator to appear only in conjunction with the name. --- lib-php/TokenSpecialTerm.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib-php/TokenSpecialTerm.php b/lib-php/TokenSpecialTerm.php index 5b2d4c70..6eb2ede3 100644 --- a/lib-php/TokenSpecialTerm.php +++ b/lib-php/TokenSpecialTerm.php @@ -44,7 +44,10 @@ class SpecialTerm */ public function isExtendable($oSearch, $oPosition) { - return !$oSearch->hasOperator() && $oPosition->isPhrase(''); + return !$oSearch->hasOperator() + && $oPosition->isPhrase('') + && ($this->iOperator != \Nominatim\Operator::NONE + || (!$oSearch->hasAddress() && !$oSearch->hasHousenumber() && !$oSearch->hasCountry())); } /** @@ -66,8 +69,8 @@ class SpecialTerm $iOp = \Nominatim\Operator::NAME; } else { $iOp = \Nominatim\Operator::NEAR; + $iSearchCost += 2; } - $iSearchCost += 2; } elseif (!$oPosition->isFirstToken() && !$oPosition->isLastToken()) { $iSearchCost += 2; } -- 2.39.5