]> git.openstreetmap.org Git - nominatim.git/commitdiff
higher penalty for special searches
authorSarah Hoffmann <lonvia@denofr.de>
Thu, 11 Mar 2021 19:34:21 +0000 (20:34 +0100)
committerSarah Hoffmann <lonvia@denofr.de>
Thu, 11 Mar 2021 19:37:51 +0000 (20:37 +0100)
Adds a general higher penalty for special search term and an
additional one if the term is anywhere but the beginning or the
end. Also housenumbers and special searches together are less
likely.

lib-php/SearchDescription.php

index 8e8e5acbb02dbad958328359d091bf118d6927c3..94cadda322ce5e1f113555bf71495d2b69028221 100644 (file)
@@ -219,6 +219,9 @@ class SearchDescription
                 $oSearch = clone $this;
                 $oSearch->iSearchRank++;
                 $oSearch->sHouseNumber = $oSearchTerm->sToken;
+                if ($this->iOperator != Operator::NONE) {
+                    $oSearch->iSearchRank++;
+                }
                 // sanity check: if the housenumber is not mainly made
                 // up of numbers, add a penalty
                 if (preg_match('/\\d/', $oSearch->sHouseNumber) === 0
@@ -255,7 +258,7 @@ class SearchDescription
         ) {
             if ($this->iOperator == Operator::NONE) {
                 $oSearch = clone $this;
-                $oSearch->iSearchRank++;
+                $oSearch->iSearchRank += 2;
 
                 $iOp = $oSearchTerm->iOperator;
                 if ($iOp == Operator::NONE) {
@@ -265,6 +268,11 @@ class SearchDescription
                         $iOp = Operator::NEAR;
                     }
                     $oSearch->iSearchRank += 2;
+                } else if (!$bFirstToken && !$bLastToken) {
+                    $oSearch->iSearchRank += 2;
+                }
+                if ($this->sHouseNumber) {
+                    $oSearch->iSearchRank++;
                 }
 
                 $oSearch->setPoiSearch(