[Lizmap] Behaviour of search in Lizmap
G. Wagner, Wagner-IT
info at wagner-it.de
Sun Jun 12 11:11:08 PDT 2022
Hi Sindile,
Thank you very much for the detailed explanations.
I will test it in the next few days.
Regards,
Günter
Von: Sindile Bidla <sindile.bidla at geoilocate.co.za>
Gesendet: Samstag, 11. Juni 2022 17:25
An: G. Wagner, Wagner-IT <info at wagner-it.de>; lizmap at lists.osgeo.org
Betreff: Re: [Lizmap] Behaviour of search in Lizmap
Hello,
Yes it is.
I followed the documentation here - https://docs.lizmap.com/current/en/publish/configuration/spatial_search.html#postgresql-search
My setup is using docker-compose
In my spatial database:
-- Add the extension pg_trgm
CREATE EXTENSION IF NOT EXISTS pg_trgm;
-- Add the extension unaccent, available with PostgreSQL contrib tools. This is needed to provide searches which are not sensitive to accentuated characters.
CREATE EXTENSION IF NOT EXISTS unaccent;
-- Add the f_unaccent function to be used in the index
CREATE OR REPLACE FUNCTION public.f_unaccent(text)
RETURNS text AS
$func$
SELECT public.unaccent('public.unaccent', $1) -- schema-qualify function and dictionary
$func$ LANGUAGE sql IMMUTABLE;
the I ran this:
replace Commune with the name of you want to use for item_layer
replace the parameters for concat(fielda, ' - ', fieldb) - I am sure you can concatenate more than two fields. If it is a single field then fieldname AS item_label
replace cadastre.geo_commume with own table (qualify with schema name if not in public schema)
You will use UNION ALL if you have another table you want to search on - can read this about UNION ALL https://www.postgresqltutorial.com/postgresql-tutorial/postgresql-union/
DROP MATERIALIZED VIEW IF EXISTS lizmap_search;
CREATE MATERIALIZED VIEW lizmap_search AS
SELECT
'Commune' AS item_layer, -- name of the layer presented to the user
concat(idu, ' - ', tex2) AS item_label, -- the search label is a concatenation between the 'Commune' code (idu) and its name (tex2)
NULL AS item_filter, -- the data will be searchable for every Lizmap user
NULL AS item_project, -- the data will be searchable for every Lizmap maps (published QGIS projects)
geom -- geometry of the 'Commune'. You could also use a simplified version, for example: ST_Envelope(geom) AS geom
FROM cadastre.geo_commune
UNION ALL -- combine the data between the 'Commune' (above) and the 'Parcelles' (below) tables
SELECT
'Parcelles' AS item_layer,
concat(code, ' - ', proprietaire) AS item_label,
'admins' AS item_filter, -- only users in the admins Lizmap group will be able to search among the 'Parcelles'
'cadastre,urban' AS item_project, -- the Parcelles will be available in search only for the cadastre.qgs and urban.qgs QGIS projects
geom
FROM cadastre.parcelle_info
;
Then create an index
-- Create the index on the unaccentuated item_label column:
DROP INDEX IF EXISTS lizmap_search_idx;
CREATE INDEX lizmap_search_idx ON lizmap_search USING GIN (f_unaccent(item_label) gin_trgm_ops);
Add a new database connection profile in Lizmap configuration file lizmap/var/config/profiles.ini.php
Hope I have been helpful.
Regards,
Sindile
On Sat, 11 Jun 2022 at 16:41, G. Wagner, Wagner-IT <info at wagner-it.de <mailto:info at wagner-it.de> > wrote:
Hi Sindile,
I have no answer to this question, but I have a question about the search:
Is this the SQL search (Postgres)?
I'm trying to implement this for a long time, unfortunately without success.
https://lists.osgeo.org/pipermail/lizmap/2022-May/000455.html
Do you have any tips / hints for me?
Or do you possibly even have a small sample database?
Regards,
Günter
Von: Lizmap <lizmap-bounces at lists.osgeo.org <mailto:lizmap-bounces at lists.osgeo.org> > Im Auftrag von Sindile Bidla
Gesendet: Samstag, 11. Juni 2022 13:19
An: lizmap at lists.osgeo.org <mailto:lizmap at lists.osgeo.org>
Betreff: [Lizmap] Behaviour of search in Lizmap
Hello,
I have implemented lizmap_search and it is working.
I am not sure though if auto-complete (like type ahead) is not available.
The current workflow I use is:
1. type the search string
2. hit enter (no results show until one hits enter)
3. choose the correct value
Is the above the default behaviour
I was expecting a behaviour similar to Locating.
Regards,
Sindile
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/lizmap/attachments/20220612/70debf0b/attachment-0001.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image001.png
Type: image/png
Size: 31522 bytes
Desc: not available
URL: <http://lists.osgeo.org/pipermail/lizmap/attachments/20220612/70debf0b/attachment-0001.png>
More information about the Lizmap
mailing list