osm-search / Nominatim

Open Source search based on OpenStreetMap data
https://nominatim.org
GNU General Public License v3.0
3.22k stars 716 forks source link

Nominatim search issue #3585

Closed rgbsi-pp3 closed 2 weeks ago

rgbsi-pp3 commented 2 weeks ago

Discussed in https://github.com/osm-search/Nominatim/discussions/3584

Originally posted by **rgbsi-pp3** November 13, 2024 Hi all, I am facing an error while searching place via nominatim. I have enabled the nominatim debug & the following is the error log: postgres@forlinx:/run/media/mmcblk1p1/nominatim-project$ nominatim search --query Bangalore 2024-11-13 09:09:13: Using project directory: /run/media/mmcblk1p1/nominatim-project 2024-11-13 09:09:13,419 INFO sqlalchemy.engine.Engine select pg_catalog.version() 2024-11-13 09:09:13: select pg_catalog.version() 2024-11-13 09:09:13,420 INFO sqlalchemy.engine.Engine [raw sql] () 2024-11-13 09:09:13: [raw sql] () 2024-11-13 09:09:13,433 INFO sqlalchemy.engine.Engine select current_schema() 2024-11-13 09:09:13: select current_schema() 2024-11-13 09:09:13,434 INFO sqlalchemy.engine.Engine [raw sql] () 2024-11-13 09:09:13: [raw sql] () 2024-11-13 09:09:13,447 INFO sqlalchemy.engine.Engine show standard_conforming_strings 2024-11-13 09:09:13: show standard_conforming_strings 2024-11-13 09:09:13,448 INFO sqlalchemy.engine.Engine [raw sql] () 2024-11-13 09:09:13: [raw sql] () 2024-11-13 09:09:13,454 INFO sqlalchemy.engine.Engine BEGIN (implicit) 2024-11-13 09:09:13: BEGIN (implicit) 2024-11-13 09:09:13,456 INFO sqlalchemy.engine.Engine SHOW server_version_num 2024-11-13 09:09:13: SHOW server_version_num 2024-11-13 09:09:13,457 INFO sqlalchemy.engine.Engine [generated in 0.00088s] () 2024-11-13 09:09:13: [generated in 0.00088s] () 2024-11-13 09:09:13,461 INFO sqlalchemy.engine.Engine SET jit_above_cost TO '-1' 2024-11-13 09:09:13: SET jit_above_cost TO '-1' 2024-11-13 09:09:13,462 INFO sqlalchemy.engine.Engine [generated in 0.00098s] () 2024-11-13 09:09:13: [generated in 0.00098s] () 2024-11-13 09:09:13,465 INFO sqlalchemy.engine.Engine SET max_parallel_workers_per_gather TO '0' 2024-11-13 09:09:13: SET max_parallel_workers_per_gather TO '0' 2024-11-13 09:09:13,466 INFO sqlalchemy.engine.Engine [generated in 0.00096s] () 2024-11-13 09:09:13: [generated in 0.00096s] () 2024-11-13 09:09:13,468 INFO sqlalchemy.engine.Engine COMMIT 2024-11-13 09:09:13: COMMIT 2024-11-13 09:09:13,502 INFO sqlalchemy.engine.Engine BEGIN (implicit) 2024-11-13 09:09:13: BEGIN (implicit) 2024-11-13 09:09:13,513 INFO sqlalchemy.engine.Engine SELECT nominatim_properties.value FROM nominatim_properties WHERE nominatim_properties.property = %s 2024-11-13 09:09:13: SELECT nominatim_properties.value FROM nominatim_properties WHERE nominatim_properties.property = %s 2024-11-13 09:09:13,513 INFO sqlalchemy.engine.Engine [generated in 0.00129s] ('tokenizer',) 2024-11-13 09:09:13: [generated in 0.00129s] ('tokenizer',) 2024-11-13 09:09:13,608 INFO sqlalchemy.engine.Engine SELECT nominatim_properties.value FROM nominatim_properties WHERE nominatim_properties.property = %s 2024-11-13 09:09:13: SELECT nominatim_properties.value FROM nominatim_properties WHERE nominatim_properties.property = %s 2024-11-13 09:09:13,608 INFO sqlalchemy.engine.Engine [cached since 0.09646s ago] ('tokenizer_import_normalisation',) 2024-11-13 09:09:13: [cached since 0.09646s ago] ('tokenizer_import_normalisation',) 2024-11-13 09:09:13,779 INFO sqlalchemy.engine.Engine SELECT nominatim_properties.value FROM nominatim_properties WHERE nominatim_properties.property = %s 2024-11-13 09:09:13: SELECT nominatim_properties.value FROM nominatim_properties WHERE nominatim_properties.property = %s 2024-11-13 09:09:13,780 INFO sqlalchemy.engine.Engine [cached since 0.268s ago] ('tokenizer_import_transliteration',) 2024-11-13 09:09:13: [cached since 0.268s ago] ('tokenizer_import_transliteration',) 2024-11-13 09:09:13,858 INFO sqlalchemy.engine.Engine SELECT word.word_id, word.word_token, word.type, word.word, word.info FROM word WHERE word.word_token IN (%s) 2024-11-13 09:09:13: SELECT word.word_id, word.word_token, word.type, word.word, word.info FROM word WHERE word.word_token IN (%s) 2024-11-13 09:09:13,859 INFO sqlalchemy.engine.Engine [generated in 0.00162s] ('bangalore',) 2024-11-13 09:09:13: [generated in 0.00162s] ('bangalore',) 2024-11-13 09:09:13,957 INFO sqlalchemy.engine.Engine WITH searches AS (SELECT anon_1.place_id AS place_id, anon_1.search_rank AS search_rank, anon_1.address_rank AS address_rank, anon_1.country_code AS country_code, anon_1.centroid AS centroid, anon_1.importance AS importance, anon_1.penalty AS penalty FROM (SELECT anon_2.place_id AS place_id, anon_2.search_rank AS search_rank, anon_2.address_rank AS address_rank, anon_2.country_code AS country_code, anon_2.centroid AS centroid, anon_2.importance AS importance, anon_2.penalty AS penalty, first_value(anon_2.penalty - anon_2.importance) OVER (ORDER BY anon_2.penalty - anon_2.importance) AS min_penalty FROM (SELECT search_name.place_id AS place_id, search_name.search_rank AS search_rank, search_name.address_rank AS address_rank, search_name.country_code AS country_code, search_name.centroid AS centroid, search_name.name_vector AS name_vector, search_name.nameaddress_vector AS nameaddress_vector, CASE WHEN (search_name.importance > %s) THEN search_name.importance ELSE %s - CAST(search_name.search_rank AS FLOAT) / %s END AS importance, %s + weigh_search(search_name.name_vector, %s, %s) AS penalty FROM search_name WHERE (search_name.name_vector @> %s) ORDER BY importance DESC LIMIT %s) AS anon_2) AS anon_1 WHERE anon_1.penalty - anon_1.importance < anon_1.min_penalty + %s) SELECT placex.place_id, placex.osm_type, placex.osm_id, placex.name, placex.class, placex.type, placex.address, placex.extratags, placex.housenumber, placex.postcode, placex.country_code, placex.wikipedia, placex.parent_place_id, placex.rank_address, placex.rank_search, placex.linked_place_id, placex.admin_level, ST_AsEWKB(placex.centroid) AS centroid, ST_AsEWKB(ST_Expand(placex.geometry, %s)) AS bbox, searches.importance, searches.penalty AS accuracy FROM placex JOIN searches ON placex.place_id = searches.place_id WHERE placex.linked_place_id IS NULL AND placex.indexed_status = %s ORDER BY searches.penalty - searches.importance, accuracy LIMIT %s 2024-11-13 09:09:13: WITH searches AS (SELECT anon_1.place_id AS place_id, anon_1.search_rank AS search_rank, anon_1.address_rank AS address_rank, anon_1.country_code AS country_code, anon_1.centroid AS centroid, anon_1.importance AS importance, anon_1.penalty AS penalty FROM (SELECT anon_2.place_id AS place_id, anon_2.search_rank AS search_rank, anon_2.address_rank AS address_rank, anon_2.country_code AS country_code, anon_2.centroid AS centroid, anon_2.importance AS importance, anon_2.penalty AS penalty, first_value(anon_2.penalty - anon_2.importance) OVER (ORDER BY anon_2.penalty - anon_2.importance) AS min_penalty FROM (SELECT search_name.place_id AS place_id, search_name.search_rank AS search_rank, search_name.address_rank AS address_rank, search_name.country_code AS country_code, search_name.centroid AS centroid, search_name.name_vector AS name_vector, search_name.nameaddress_vector AS nameaddress_vector, CASE WHEN (search_name.importance > %s) THEN search_name.importance ELSE %s - CAST(search_name.search_rank AS FLOAT) / %s END AS importance, %s + weigh_search(search_name.name_vector, %s, %s) AS penalty FROM search_name WHERE (search_name.name_vector @> %s) ORDER BY importance DESC LIMIT %s) AS anon_2) AS anon_1 WHERE anon_1.penalty - anon_1.importance < anon_1.min_penalty + %s) SELECT placex.place_id, placex.osm_type, placex.osm_id, placex.name, placex.class, placex.type, placex.address, placex.extratags, placex.housenumber, placex.postcode, placex.country_code, placex.wikipedia, placex.parent_place_id, placex.rank_address, placex.rank_search, placex.linked_place_id, placex.admin_level, ST_AsEWKB(placex.centroid) AS centroid, ST_AsEWKB(ST_Expand(placex.geometry, %s)) AS bbox, searches.importance, searches.penalty AS accuracy FROM placex JOIN searches ON placex.place_id = searches.place_id WHERE placex.linked_place_id IS NULL AND placex.indexed_status = %s ORDER BY searches.penalty - searches.importance, accuracy LIMIT %s 2024-11-13 09:09:13,958 INFO sqlalchemy.engine.Engine [generated in 0.00280s] (0, 0.40001, 75, 0.0, '[[0.0,[241022]]]', 0.5, [5452], 10000, 0.5, 0, 0, 20) 2024-11-13 09:09:13: [generated in 0.00280s] (0, 0.40001, 75, 0.0, '[[0.0,[241022]]]', 0.5, [5452], 10000, 0.5, 0, 0, 20) 2024-11-13 09:09:15,285 INFO sqlalchemy.engine.Engine SELECT CAST(anon_1.value ->> %s AS INTEGER) AS src_place_id, placex.place_id, placex.osm_type, placex.osm_id, placex.name, placex.class, placex.type, placex.extratags, placex.admin_level, place_addressline.fromarea, CASE WHEN (placex.rank_address = %s) THEN %s ELSE placex.rank_address END AS rank_address, place_addressline.distance, placex.country_code, placex.postcode FROM json_array_elements(%s) AS anon_1 JOIN place_addressline ON place_addressline.place_id = CAST((anon_1.value ->> %s) AS INTEGER) OR place_addressline.place_id = CAST((anon_1.value ->> %s) AS INTEGER) JOIN placex ON place_addressline.address_place_id = placex.place_id ORDER BY src_place_id, rank_address DESC, place_addressline.place_id = CAST((anon_1.value ->> %s) AS INTEGER) DESC, CASE WHEN coalesce(avals(placex.name) && ARRAY(SELECT * FROM json_array_elements_text(anon_1.value -> %s)), false) THEN %s WHEN place_addressline.isaddress THEN %s WHEN (place_addressline.fromarea AND ST_Contains(placex.geometry, ST_GeomFromEWKT(CAST(anon_1.value ->> %s AS VARCHAR)))) THEN %s ELSE %s END DESC, place_addressline.fromarea DESC, place_addressline.distance DESC, placex.rank_search DESC 2024-11-13 09:09:15: SELECT CAST(anon_1.value ->> %s AS INTEGER) AS src_place_id, placex.place_id, placex.osm_type, placex.osm_id, placex.name, placex.class, placex.type, placex.extratags, placex.admin_level, place_addressline.fromarea, CASE WHEN (placex.rank_address = %s) THEN %s ELSE placex.rank_address END AS rank_address, place_addressline.distance, placex.country_code, placex.postcode FROM json_array_elements(%s) AS anon_1 JOIN place_addressline ON place_addressline.place_id = CAST((anon_1.value ->> %s) AS INTEGER) OR place_addressline.place_id = CAST((anon_1.value ->> %s) AS INTEGER) JOIN placex ON place_addressline.address_place_id = placex.place_id ORDER BY src_place_id, rank_address DESC, place_addressline.place_id = CAST((anon_1.value ->> %s) AS INTEGER) DESC, CASE WHEN coalesce(avals(placex.name) && ARRAY(SELECT * FROM json_array_elements_text(anon_1.value -> %s)), false) THEN %s WHEN place_addressline.isaddress THEN %s WHEN (place_addressline.fromarea AND ST_Contains(placex.geometry, ST_GeomFromEWKT(CAST(anon_1.value ->> %s AS VARCHAR)))) THEN %s ELSE %s END DESC, place_addressline.fromarea DESC, place_addressline.distance DESC, placex.rank_search DESC 2024-11-13 09:09:15,286 INFO sqlalchemy.engine.Engine [generated in 0.00290s] ('pid', 11, 5, '[{"pid": 7819670, "lid": 7819670, "names": ["560001", "IN-KA"], "c": "SRID=4326;POINT(77.590082 12.9767936)"}, {"pid": 7816449, "lid": 7816449, "name ... (861 characters truncated) ... "c": "SRID=4326;POINT(77.70540295967255 12.994626449999998)"}, {"pid": 8012027, "lid": 8012027, "names": [], "c": "SRID=4326;POINT(77.583333 13.0)"}]', 'pid', 'lid', 'pid', 'names', 2, 0, 'c', 1, -1) 2024-11-13 09:09:15: [generated in 0.00290s] ('pid', 11, 5, '[{"pid": 7819670, "lid": 7819670, "names": ["560001", "IN-KA"], "c": "SRID=4326;POINT(77.590082 12.9767936)"}, {"pid": 7816449, "lid": 7816449, "name ... (861 characters truncated) ... "c": "SRID=4326;POINT(77.70540295967255 12.994626449999998)"}, {"pid": 8012027, "lid": 8012027, "names": [], "c": "SRID=4326;POINT(77.583333 13.0)"}]', 'pid', 'lid', 'pid', 'names', 2, 0, 'c', 1, -1) Traceback (most recent call last): File "/usr/bin/nominatim", line 13, in osm2pgsql_path='/usr/lib/nominatim/osm2pgsql')) File "/usr/lib/nominatim/lib-python/nominatim/cli.py", line 228, in nominatim return get_set_parser().run(**kwargs) File "/usr/lib/nominatim/lib-python/nominatim/cli.py", line 121, in run return args.command.run(args) File "/usr/lib/nominatim/lib-python/nominatim/clicmd/api.py", line 118, in run results = api.search(args.query, **params) File "/usr/lib/nominatim/lib-python/nominatim/api/core.py", line 748, in search self._async_api.search(query, **params)) File "usr/lib/python3.7/asyncio/base_events.py", line 584, in run_until_complete File "/usr/lib/nominatim/lib-python/nominatim/api/core.py", line 261, in search return await geocoder.lookup(phrases) File "/usr/lib/nominatim/lib-python/nominatim/api/search/geocoder.py", line 216, in lookup await add_result_details(self.conn, results, self.params) File "/usr/lib/nominatim/lib-python/nominatim/api/results.py", line 451, in add_result_details await complete_address_details(conn, results) File "/usr/lib/nominatim/lib-python/nominatim/api/results.py", line 627, in complete_address_details for row in await conn.execute(sql): File "/usr/lib/nominatim/lib-python/nominatim/api/connection.py", line 63, in execute return await asyncio.wait_for(self.connection.execute(sql, params), self.query_timeout) File "usr/lib/python3.7/asyncio/tasks.py", line 423, in wait_for concurrent.futures._base.TimeoutError I have given the following configurations in postgresql.conf (Recommended by nominatim docs): shared_buffers = 2GB maintenance_work_mem = (10GB) autovacuum_work_mem = 2GB work_mem = (50MB) synchronous_commit = off max_wal_size = 1GB checkpoint_timeout = 60min checkpoint_completion_target = 0.9 random_page_cost = 1.0 wal_level = minimal max_wal_senders = 0 autovacuum_max_workers = 1 kindly provide me the solution for this error as I got stuck with this issue. Thanks in advance.
mtmail commented 2 weeks ago

Duplicate of the linked discussion