Skip to content

Commit 11bedd1

Browse files
authored
Extend and clearify the documentation for defining solr facets. (#22)
1 parent 395af68 commit 11bedd1

File tree

1 file changed

+39
-19
lines changed

1 file changed

+39
-19
lines changed

src/topics/Search.md

Lines changed: 39 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,8 @@ A facet references a searchable dataset. The configuration of the fulltext searc
236236
"name": "<facet name>",
237237
"filter_word": "<filter word>",
238238
"table_name": "<schema.tablename>",
239-
"geometry_column": "<geometry column name>"
239+
"geometry_column": "<geometry column name>",
240+
"search_id_col": "<id column name>"
240241
},
241242
...
242243
]
@@ -255,6 +256,7 @@ The facets describe a searchable dataset and are referenced by the search index:
255256
- `filter_word` is a short (human readable) name which appears as result category in the search results (i.e. `Address`).
256257
- `table_name` specifies the table containing the features referenced by the search index (in the format `schema.table_name`).
257258
- `geometry_column` specifies the name of the geometry column in this table.
259+
- `search_id_col` specifies the name of the id column in this table. If unset, field from search filter expression is used.
258260

259261

260262
### Fulltext search with Trigram backend
@@ -312,7 +314,7 @@ Next, create search XML configuration files in `volumes/solr/configsets/gdi/conf
312314
'{FACET_NAME}'::text AS subclass,
313315
{PRIMARY_KEY} AS id_in_class,
314316
'{PRIMARY_KEY}' AS id_name,
315-
'{SEARCH_FIELD_DATA_TYPE}:n' AS id_type,
317+
'str:{SEARCH_FIELD_IS_STRING}' AS search_field_str,
316318
{DISPLAYTEXT} AS displaytext,
317319
{SEARCH_FIELD_1} AS search_part_1,
318320
{GEOMETRY_FIELD} AS geom
@@ -326,9 +328,10 @@ Next, create search XML configuration files in `volumes/solr/configsets/gdi/conf
326328
search_part_1 AS sort,
327329
subclass AS facet,
328330
'default' AS tenant,
329-
(array_to_json(array_append(ARRAY[id_name::text], id_type::text)))::text AS idfield_meta,
331+
(array_to_json(array_append(ARRAY[id_name::text], search_field_str::text)))::text AS idfield_meta,
330332
(st_asgeojson(st_envelope(geom), 0, 1)::json -> 'bbox')::text AS bbox,
331-
st_srid(geom) as srid
333+
id_name,
334+
geom
332335
FROM index_base">
333336
</entity>
334337
</document>
@@ -337,21 +340,38 @@ Next, create search XML configuration files in `volumes/solr/configsets/gdi/conf
337340

338341
The next table shows how the values need to be defined:
339342

340-
| **Name** | **Definition** | **Example** |
341-
|--------------------------|-----------------------------------------------------------------------------------|------------------|
342-
| `DB_HOST` | Database hostname | `qwc-postgis` |
343-
| `DB_NAME` | Database name | `qwc_demo` |
344-
| `DB_PORT` | Database port number | `5432` |
345-
| `DB_USER` | Database username | `qwc_service` |
346-
| `DB_PASSWORD` | Password for the specified database user | `qwc_service` |
347-
| `FACET_NAME` | Name of the search facet | `fluesse_search` |
348-
| `PRIMARY_KEY` | Primary key name of the table that is used in the search query | `ogc_fid` |
349-
| `SEARCH_FIELD_DATA_TYPE` | Search field data type | `str` |
350-
| `DISPLAYTEXT` | Displaytext that will be shown by the QWC2 when a match was found | `name_long` |
351-
| `SEARCH_FIELD_1` | Table field that will be used by the search | `name_long` |
352-
| `GEOMETRY_FIELD` | Name of the geometry column of the search table | `wkb_geometry` |
353-
| `SCHEMA` | Search table schema | `qwc_geodb` |
354-
| `SEARCH_TABLE_NAME` | Search table name | `fluesse` |
343+
| **Name** | **Definition** | **Example** |
344+
|--------------------------|------------------------------------------------------------------------------------------------|------------------|
345+
| `DB_HOST` | Database hostname | `qwc-postgis` |
346+
| `DB_NAME` | Database name | `qwc_demo` |
347+
| `DB_PORT` | Database port number | `5432` |
348+
| `DB_USER` | Database username | `qwc_service` |
349+
| `DB_PASSWORD` | Password for the specified database user | `qwc_service` |
350+
| `FACET_NAME` | Name of the search facet | `fluesse_search` |
351+
| `PRIMARY_KEY` | Primary key name of the table that is used in the search query | `ogc_fid` |
352+
| `SEARCH_FIELD_IS_STRING` | Definition, if search field is string (`y`) or not (`n`). If not, it's interpreted as integer. | `n` |
353+
| `DISPLAYTEXT` | Displaytext that will be shown by the QWC2 when a match was found | `name_long` |
354+
| `SEARCH_FIELD_1` | Table field that will be used by the search | `name_long` |
355+
| `GEOMETRY_FIELD` | Name of the geometry column of the search table | `wkb_geometry` |
356+
| `SCHEMA` | Search table schema | `qwc_geodb` |
357+
| `SEARCH_TABLE_NAME` | Search table name | `fluesse` |
358+
359+
**Hint**: For a less complex configuration file, of course it is also possible to define the query within a `VIEW` definition within the database. In this case just provide the query within the facet configuration like:
360+
```xml
361+
<entity name="{FACET_NAME}" query="
362+
SELECT id,
363+
display,
364+
search_1_stem,
365+
sort,
366+
facet,
367+
tenant,
368+
idfield_meta,
369+
bbox
370+
id_name,
371+
geom
372+
FROM index_base">
373+
</entity>
374+
```
355375

356376
*Note*:
357377
In the case of several searches sharing the same database connection,

0 commit comments

Comments
 (0)