You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -313,6 +315,18 @@ The `trgm_layer_query` must return the following fields:
313
315
314
316
*Note*: The layer query relies on an additional service, configured as `dataproductServiceUrl` in the viewer `config.json`, which resolves the `dataproduct_id` to a QWC theme sublayer object, like the [`sogis-dataproduct-service`](https://github.com/qwc-services/sogis-dataproduct-service).
315
317
318
+
In alternative to specifying `trgm_feature_query` and/or `trgm_layer_query`, you can set `trgm_feature_query_template` and/or `trgm_layer_query_template` to a [Jinja template string](https://jinja.palletsprojects.com/en/stable/templates/) which generates the final SQL query. The following variables are available in the template string:
319
+
320
+
*`searchtext`: the full search text, as a string
321
+
*`words`: the single words of the search text, as an array
322
+
*`facets`: the permitted search facets, as an array
323
+
324
+
Example for `trgm_feature_query_template` to generate an "unrolled" query for each word in the searchtext:
325
+
326
+
SELECT display, facet_id, id_field_name, feature_id, bbox, srid FROM public.search_index
327
+
WHERE {% for word in words %} searchterms ILIKE '%' || '{{ word }}' || '%' {% if not loop.last %} AND {% endif %} {% endfor %}
328
+
ORDER BY {% for word in words %} similarity(searchterms, '{{ word }}') {% if not loop.last %} + {% endif %} {% endfor %} DESC
329
+
316
330
*Note*: Set `FLASK_DEBUG=1` as environment variable for the search service to see additional logging information.
0 commit comments