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
Copy file name to clipboardExpand all lines: src/topics/Search.md
+99-55Lines changed: 99 additions & 55 deletions
Original file line number
Diff line number
Diff line change
@@ -207,12 +207,94 @@ In addition to the configuration described above, you can specify these addition
207
207
208
208
## Configuring the fulltext search service <aname="fulltext-search"></a>
209
209
210
-
### Solr configuration
210
+
The [`qwc-fulltet-search-service`](https://github.com/qwc-services/qwc-fulltet-search-service) provides facetted fullsearch text search, with one of the following backends:
211
211
212
-
Before the fulltext search service can be configured, a new solr configuration file must be created.
213
-
This file must be created in `volumes/solr/configsets/gdi/conf/`.
214
-
The name of the file can be chosen freely.
215
-
Here is an example XML file:
212
+
* Postgres Trigram
213
+
* Apache Solr
214
+
215
+
A facet references a searchable dataset. The configuration of the fulltext search service and available search facets can be found in `tenantConfig.json`:
- The `search_backend` specifies the search backend to use, either `solr` or `trgm`. Default: `solr`.
248
+
- The `db_url` specifies the DB which contains the search index (searched either by `solr` or by the specified `trgm` queries).
249
+
- The `word_split_re` specifies the regular expression which is used to split the search string into single words. Default: `[\\s,.:;\"]+`.
250
+
-`search_result_limit` specifies the maximum number of feature results returned by a search. Default: `50`.
251
+
252
+
The facets describe a searchable dataset and are referenced by the search index:
253
+
254
+
-`name` specifies the facet identifier.
255
+
-`filter_word` is a short (human readable) name which appears as result category in the search results (i.e. `Address`).
256
+
-`table_name` specifies the table containing the features referenced by the search index (in the format `schema.table_name`).
257
+
-`geometry_column` specifies the name of the geometry column in this table.
258
+
259
+
260
+
### Fulltext search with Trigram backend
261
+
262
+
To configure a fulltext search with the trigram backend, set `search_backend` to `trgm` and specify a `trgm_feature_query` and optionally a `trgm_layer_query`. The feature and layer query SQL can contain following placeholders:
263
+
264
+
-`:term`: The full search text
265
+
-`:terms`: A list of search text words (i.e. the full search text split by whitespace).
266
+
-`:thres`: The trigram similarity treshold value (note that the service will also separately execute `SET pg_trgm.similarity_threshold = <value>`)
267
+
268
+
The `trgm_feature_query` must return the following fields:
269
+
270
+
*`display`: The label to display in the search results.
271
+
*`facet_id`: The facet name (as configured in `resources` => `facets`).
272
+
*`id_field_name`: The name of the identifier field in the table referenced by the facet.
273
+
*`feature_id`: The feature identifier through which to locate the feature in table referenced by the facet.
274
+
*`bbox`: The feature bounding box, as a`[xmin,ymin,xmax,ymax]` string.
275
+
*`srid`: The SRID of the bbox coordinates (i.e. `3857`).
FROM public.search_index WHERE searchterms % :term OR searchterms ILIKE '%' || :term || '%' ORDER BY sml DESC;",
281
+
282
+
The `trgm_layer_query` must return the following fields:
283
+
284
+
*`display`: The label to display in the search results.
285
+
*`dataproduct_id`: The id of the dataproduct.
286
+
*`has_info`: Whether an abstract is available for the dataproduct.
287
+
*`sublayers`: A JSON stringified array of the shape `[{"ident": "<dataproduct_id>", "display": "<display>", "dset_info": true}, ...]`, or `NULL` if no sublayers exist.
288
+
289
+
*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).
290
+
291
+
*Note*: Set `FLASK_DEBUG=1` as environment variable for the search service to see additional logging information.
292
+
293
+
### Fulltext search with Solr backend
294
+
295
+
To use the solr backend, you need to run a solr search service and point `solr_service_url` to the corresponding URL. You can find the solr documentation at [https://lucene.apache.org/solr/guide/8_0/](https://lucene.apache.org/solr/guide/8_0/).
296
+
297
+
Next, create search XML configuration files in `volumes/solr/configsets/gdi/conf/`. The name of the file can be chosen freely. Example:
216
298
217
299
```xml
218
300
<dataConfig>
@@ -223,11 +305,11 @@ Here is an example XML file:
223
305
password="{DB_PASSWORD}"
224
306
/>
225
307
<document>
226
-
<entityname="{SEARCH_NAME}"query="
308
+
<entityname="{FACET_NAME}"query="
227
309
WITH index_base AS (
228
310
/* ==== Base query for search index ==== */
229
311
SELECT
230
-
'{SEARCH_NAME}'::text AS subclass,
312
+
'{FACET_NAME}'::text AS subclass,
231
313
{PRIMARY_KEY} AS id_in_class,
232
314
'{PRIMARY_KEY}' AS id_name,
233
315
'{SEARCH_FIELD_DATA_TYPE}:n' AS id_type,
@@ -262,7 +344,7 @@ The next table shows how the values need to be defined:
262
344
|`DB_PORT`| Database port number |`5432`|
263
345
|`DB_USER`| Database username |`qwc_service`|
264
346
|`DB_PASSWORD`| Password for the specified database user |`qwc_service`|
265
-
|`SEARCH_NAME`| Name of the search |`fluesse_search`|
347
+
|`FACET_NAME`| Name of the search facet|`fluesse_search`|
266
348
|`PRIMARY_KEY`| Primary key name of the table that is used in the search query |`ogc_fid`|
267
349
|`SEARCH_FIELD_DATA_TYPE`| Search field data type |`str`|
268
350
|`DISPLAYTEXT`| Displaytext that will be shown by the QWC2 when a match was found |`name_long`|
@@ -281,7 +363,7 @@ In the `volumes/solr/configsets/gdi/conf/solrconfig.xml` file you have to look f
281
363
`<!-- SearchHandler` and add the following configuration
* To manage layer search permissions, you can create a `Search facet` with name `dataproduct`.
408
+
* You can create a wildcard `Search facet` resource by setting the name to `*`. This is useful to assign permissions for all available facets with one single resource.
0 commit comments