]> git.openstreetmap.org Git - nominatim.git/commitdiff
narrow down search by house number when postcode is given
authorSarah Hoffmann <lonvia@denofr.de>
Mon, 7 May 2018 19:28:32 +0000 (21:28 +0200)
committerSarah Hoffmann <lonvia@denofr.de>
Mon, 7 May 2018 19:34:11 +0000 (21:34 +0200)
Fixes #1034.

lib/SearchDescription.php

index 07eccec488175c04c1b96a2d948c0857275d25e9..5f01e01bcf9bb78f3a2dee104aab8d8158a345d3 100644 (file)
@@ -593,7 +593,11 @@ class SearchDescription
         $aTerms = array();
         $aOrder = array();
 
-        if ($this->sHouseNumber && !empty($this->aAddress)) {
+        // Sort by existence of the requested house number but only if not
+        // too many results are expected for the street, i.e. if the result
+        // will be narrowed down by an address. Remeber that with ordering
+        // every single result has to be checked.
+        if ($this->sHouseNumber && (!empty($this->aAddress) || $this->sPostcode)) {
             $sHouseNumberRegex = '\\\\m'.$this->sHouseNumber.'\\\\M';
             $aOrder[] = ' (';
             $aOrder[0] .= 'EXISTS(';