avoid swapping, never give more than 2/3 of RAM to osm2pgsql.
+Computing word frequency for search terms can improve the performance of
+forward geocoding in particular under high load as it helps Postgres' query
+planner to make the right decisions. To recompute word counts run:
+
+ ./utils/update.php --recompute-word-counts
+
+This will take a couple of hours for a full planet installation. You can
+also defer that step to a later point in time when you realise that
+performance becomes an issue. Just make sure that updates are stopped before
+running this function.
+
Loading additional datasets
---------------------------
$iOp = Operator::NEAR; // near == in for the moment
if ($aSearchTerm['operator'] == '') {
- if (sizeof($this->aName)) {
+ if (sizeof($this->aName) || $this->oContext->isBoundedSearch()) {
$iOp = Operator::NAME;
}
$oSearch->iSearchRank += 2;
--DEBUG: RAISE WARNING 'waterway parent %, child %/%', NEW.osm_id, i, relation_members[i];
FOR linked_node_id IN SELECT place_id FROM placex
WHERE osm_type = 'W' and osm_id = substring(relation_members[i],2,200)::bigint
- and class = NEW.class and type = NEW.type
+ and class = NEW.class and type in ('river', 'stream', 'canal', 'drain', 'ditch')
and ( relation_members[i+1] != 'side_stream' or NEW.name->'name' = name->'name')
LOOP
UPDATE placex SET linked_place_id = NEW.place_id WHERE place_id = linked_node_id;
--- /dev/null
+DROP TABLE IF EXISTS word_frequencies;
+CREATE TABLE word_frequencies AS
+ SELECT unnest(name_vector) as id, count(*) FROM search_name GROUP BY id;
+
+CREATE INDEX idx_word_frequencies ON word_frequencies(id);
+
+UPDATE word SET search_name_count = count
+ FROM word_frequencies
+ WHERE word_token like ' %' and word_id = id;
+
+DROP TABLE word_frequencies;
Scenario: Relations are not linked when in waterway relations
Given the scene split-road
And the places
- | osm | class | type | name | geometry |
- | W1 | waterway | river | Rhein | :w-2 |
- | W2 | waterway | river | Rhein | :w-3 |
- | R1 | waterway | river | Rhein | :w-1 + :w-2 + :w-3 |
- | R2 | waterway | river | Limmat| :w-4a |
+ | osm | class | type | name | geometry |
+ | W1 | waterway | stream | Rhein | :w-2 |
+ | W2 | waterway | river | Rhein | :w-3 |
+ | R1 | waterway | river | Rhein | :w-1 + :w-2 + :w-3 |
+ | R2 | waterway | river | Limmat| :w-4a |
And the relations
| id | members | tags+type |
| 1 | R2 | waterway |
| object | linked_place_id |
| R1 | - |
- Scenario: Waterways are not linked when waterway types don't match
+ Scenario: Waterways are not linked when the way type is not a river feature
Given the scene split-road
And the places
| osm | class | type | name | geometry |
- | W1 | waterway | drain | Rhein | :w-2 |
+ | W1 | waterway | lock | Rhein | :w-2 |
| R1 | waterway | river | Rhein | :w-1 + :w-2 + :w-3 |
And the relations
| id | members | tags+type |
array('index-instances', '', 0, 1, 1, 1, 'int', 'Number of indexing instances (threads)'),
array('deduplicate', '', 0, 1, 0, 0, 'bool', 'Deduplicate tokens'),
+ array('recompute-word-counts', '', 0, 1, 0, 0, 'bool', 'Compute frequency of full-word search terms'),
array('no-npi', '', 0, 1, 0, 0, 'bool', '(obsolete)'),
);
getCmdOpt($_SERVER['argv'], $aCMDOptions, $aResult, true, true);
}
}
+if ($aResult['recompute-word-counts']) {
+ info('Recompute frequency of full-word search terms');
+ $sTemplate = file_get_contents(CONST_BasePath.'/sql/words_from_search_name.sql');
+ runSQLScript($sTemplate, true, true);
+}
+
if ($aResult['index']) {
passthru(CONST_InstallPath.'/nominatim/nominatim -i -d '.$aDSNInfo['database'].' -P '.$aDSNInfo['port'].' -t '.$aResult['index-instances'].' -r '.$aResult['index-rank']);
}
$oParams = new Nominatim\ParameterParser();
$sOutputFormat = 'html';
-$iDays = $oParams->getInt('days', 1);
+$iDays = $oParams->getInt('days', false);
$bReduced = $oParams->getBool('reduced', false);
$sClass = $oParams->getString('class', false);
$sSQL = 'select osm_type as "type",osm_id as "id",class as "key",type as "value",name->\'name\' as "name",';
$sSQL .= 'country_code as "country",errormessage as "error message",updated';
$sSQL .= ' from import_polygon_error';
- $sSQL .= " where updated > 'now'::timestamp - '".$iDays." day'::interval";
- $iDays++;
- if ($bReduced) $sSQL .= " and errormessage like 'Area reduced%'";
- if ($sClass) $sSQL .= " and class = '".pg_escape_string($sClass)."'";
+ $aWhere = array();
+ if ($iDays) {
+ $aWhere[] = "updated > 'now'::timestamp - '".$iDays." day'::interval";
+ $iDays++;
+ }
+
+ if ($bReduced) $aWhere[] = "errormessage like 'Area reduced%'";
+ if ($sClass) $sWhere[] = "class = '".pg_escape_string($sClass)."'";
+
+ if (sizeof($aWhere)) {
+ $sSQL .= ' where '.join(' and ', $aWhere);
+ }
+
$sSQL .= ' order by updated desc limit 1000';
$aPolygons = chksql($oDB->getAll($sSQL));
}