Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add forward search capability for SQLite databases #3273

Merged
merged 17 commits into from
Dec 12, 2023

Conversation

lonvia
Copy link
Member

@lonvia lonvia commented Dec 12, 2023

This adds the remaining search capabilities to SQLite databases including category search.

SQLite has neither an intarray type nor GIN indexes. Both are needed for Nominatim's central search index. The SQLite implementation uses an explicit reverse lookup table instead and uses a custom type that saves intarrays in text fields.

This PR also contains some cleanup of the SQLAlchemy wrapper code. Types that are different between SQLite and PostgreSQL are not properly wrapped in a single class with dynamic instantiation according to the database used. Geometry functions now clearly state when they should use an index. The typing of @compile functions should now be more correct.

Finally, connection pools are enabled for SQLite. SQLAlchemy doesn't do that by default because connecting to a SQLite database is superfast. However, given that we need to load the spatialite extension, the delay in opening a new connection is noticable for Nominatim. The old behaviour can be reenabled by setting NOMINATIM_API_POOL_SIZE to 0.

lonvia added 17 commits December 7, 2023 09:31
Also define a custom set of operators in preparation of differences
in implementation.
Connecting is reasonably expensive because the spatialite extension
needs to be loaded. Disable pooling for tests because there is some
memory leak when quickly opening and closing QueuePools with sqlite
connections.
Use JSON arrays which can have mixed types and therefore have
a more logical structure than separate arrays. Avoid JSON dicts
because of their verboseness.
A non-index version of ST_DWithin is not necessary. ST_Distance
can be used for that purpose. Index use for intersects can be
covered with a simple parameter.
Use function classes which can be instantiated directly.
Also improves on the decision if an indexed is used or not.
The first parameter is in fact the self parameter referring to
the function class.
Requires to mark the databse r/w when it is newly created in the
convert function.
@lonvia lonvia merged commit af85ad3 into osm-search:master Dec 12, 2023
9 checks passed
@lonvia lonvia deleted the search-with-sqlite branch December 12, 2023 11:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant