diff --git a/docs/install.md b/docs/install.md index 45c62c2a..02f13236 100644 --- a/docs/install.md +++ b/docs/install.md @@ -84,13 +84,6 @@ may want to add an index. For that, you should do so: CREATE EXTENSION unaccent; CREATE EXTENSION btree_gin; - ALTER FUNCTION unaccent(text) IMMUTABLE; - ALTER FUNCTION to_tsvector(text) IMMUTABLE; - CREATE INDEX search_idx ON umap_map USING gin(to_tsvector(unaccent(name)), share_status); - - -## Optimisations - -To speed up uMap homepage rendering on a large instance, the following index can be added as well (make sure you set the center to your default instance map center): - - CREATE INDEX umap_map_optim ON umap_map (modified_at) WHERE ("umap_map"."share_status" = 1 AND ST_Distance("umap_map"."center", ST_GeomFromEWKT('SRID=4326;POINT(2 51)')) > 1000.0); + CREATE TEXT SEARCH CONFIGURATION umapdict (COPY=simple); + ALTER TEXT SEARCH CONFIGURATION umapdict ALTER MAPPING FOR hword, hword_part, word WITH unaccent, simple; + CREATE INDEX IF NOT EXISTS search_idx ON umap_map USING GIN(to_tsvector('umapdict', name), share_status); diff --git a/umap/views.py b/umap/views.py index 55c0c74a..2c193fa9 100644 --- a/umap/views.py +++ b/umap/views.py @@ -190,9 +190,9 @@ class Search(TemplateView, PaginatorMixin): q = self.request.GET.get("q") results = [] if q: - where = "to_tsvector(name) @@ plainto_tsquery(%s)" + where = "to_tsvector(name) @@ websearch_to_tsquery(%s)" if getattr(settings, "UMAP_USE_UNACCENT", False): - where = "to_tsvector(unaccent(name)) @@ plainto_tsquery(unaccent(%s))" # noqa + where = "to_tsvector(unaccent(name)) @@ websearch_to_tsquery(unaccent(%s))" # noqa results = Map.objects.filter(share_status=Map.PUBLIC) results = results.extra(where=[where], params=[q]) results = results.order_by("-modified_at")