Skip to content

Commit

Permalink
Merge pull request #26 from PDOK/changes_search_index
Browse files Browse the repository at this point in the history
Changes search index
  • Loading branch information
rkettelerij authored Jan 13, 2025
2 parents e297505 + 87046ff commit 5999a76
Show file tree
Hide file tree
Showing 7 changed files with 137 additions and 137 deletions.
2 changes: 1 addition & 1 deletion internal/etl/load/postgres.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ func (p *Postgres) Init(index string) error {

fullTextSearchColumn := fmt.Sprintf(`
alter table %[1]s add column if not exists ts tsvector
generated always as (to_tsvector('dutch', suggest || display_name )) stored;`, index)
generated always as (to_tsvector('simple', suggest)) stored;`, index)
_, err = p.db.Exec(p.ctx, fullTextSearchColumn)
if err != nil {
return fmt.Errorf("error creating full-text search column: %w", err)
Expand Down
4 changes: 2 additions & 2 deletions internal/search/datasources/postgres/postgres.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ func makeSearchQuery(index string, srid d.SRID) string {
// language=postgresql
query := fmt.Sprintf(`
with query as (
select to_tsquery('dutch', $2) query
select to_tsquery('simple', $2) query
)
select r.display_name as display_name,
max(r.feature_id) as feature_id,
Expand All @@ -88,7 +88,7 @@ func makeSearchQuery(index string, srid d.SRID) string {
from (
select display_name, feature_id, collection_id, collection_version, geometry_type, bbox,
ts_rank_cd(ts, (select query from query), 1) as rank,
ts_headline('dutch', display_name, (select query from query)) as highlighted_text
ts_headline('simple', display_name, (select query from query)) as highlighted_text
from %[1]s
where ts @@ (select query from query) and (collection_id, collection_version) in (
-- make a virtual table by creating tuples from the provided arrays.
Expand Down
2 changes: 1 addition & 1 deletion internal/search/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ func TestSearch(t *testing.T) {
},
},
{
name: "Search: 'Den' in another collection in RD",
name: "Search: 'Den' in another collection in WGS84",
fields: fields{
url: "http://localhost:8080/search?q=\"Den\"&buildings[version]=1&limit=10&f=json",
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"displayName": "Abbewaal - Den Burg 1",
"highlight": "Abbewaal - <b>Den</b> Burg 1",
"href": "https://example.com/ogc/v1/collections/buildings/items/51?f=json",
"score": 0.10277967154979706
"score": 0.07213475555181503
},
"geometry": {
"type": "Polygon",
Expand Down Expand Up @@ -67,7 +67,7 @@
"displayName": "Abbewaal - Den Burg 1",
"highlight": "Abbewaal - <b>Den</b> Burg 1",
"href": "https://example.com/ogc/v1/collections/buildings/items/52?f=json",
"score": 0.10277967154979706
"score": 0.07213475555181503
},
"geometry": {
"type": "Polygon",
Expand Down Expand Up @@ -115,7 +115,7 @@
"displayName": "Abbewaal - Den Burg 10",
"highlight": "Abbewaal - <b>Den</b> Burg 10",
"href": "https://example.com/ogc/v1/collections/buildings/items/32183?f=json",
"score": 0.10277967154979706
"score": 0.07213475555181503
},
"geometry": {
"type": "Polygon",
Expand Down Expand Up @@ -163,7 +163,7 @@
"displayName": "Abbewaal - Den Burg 10",
"highlight": "Abbewaal - <b>Den</b> Burg 10",
"href": "https://example.com/ogc/v1/collections/buildings/items/53?f=json",
"score": 0.10277967154979706
"score": 0.07213475555181503
},
"geometry": {
"type": "Polygon",
Expand Down Expand Up @@ -211,7 +211,7 @@
"displayName": "Abbewaal - Den Burg 10",
"highlight": "Abbewaal - <b>Den</b> Burg 10",
"href": "https://example.com/ogc/v1/collections/buildings/items/32184?f=json",
"score": 0.10277967154979706
"score": 0.07213475555181503
},
"geometry": {
"type": "Polygon",
Expand Down Expand Up @@ -259,7 +259,7 @@
"displayName": "Abbewaal - Den Burg 10",
"highlight": "Abbewaal - <b>Den</b> Burg 10",
"href": "https://example.com/ogc/v1/collections/buildings/items/54?f=json",
"score": 0.10277967154979706
"score": 0.07213475555181503
},
"geometry": {
"type": "Polygon",
Expand Down Expand Up @@ -307,7 +307,7 @@
"displayName": "Abbewaal - Den Burg 11",
"highlight": "Abbewaal - <b>Den</b> Burg 11",
"href": "https://example.com/ogc/v1/collections/buildings/items/22549?f=json",
"score": 0.10277967154979706
"score": 0.07213475555181503
},
"geometry": {
"type": "Polygon",
Expand Down Expand Up @@ -355,7 +355,7 @@
"displayName": "Abbewaal - Den Burg 13",
"highlight": "Abbewaal - <b>Den</b> Burg 13",
"href": "https://example.com/ogc/v1/collections/buildings/items/56?f=json",
"score": 0.10277967154979706
"score": 0.07213475555181503
},
"geometry": {
"type": "Polygon",
Expand Down Expand Up @@ -403,7 +403,7 @@
"displayName": "Abbewaal - Den Burg 13",
"highlight": "Abbewaal - <b>Den</b> Burg 13",
"href": "https://example.com/ogc/v1/collections/buildings/items/55?f=json",
"score": 0.10277967154979706
"score": 0.07213475555181503
},
"geometry": {
"type": "Polygon",
Expand Down Expand Up @@ -451,7 +451,7 @@
"displayName": "Abbewaal - Den Burg 15",
"highlight": "Abbewaal - <b>Den</b> Burg 15",
"href": "https://example.com/ogc/v1/collections/buildings/items/57?f=json",
"score": 0.10277967154979706
"score": 0.07213475555181503
},
"geometry": {
"type": "Polygon",
Expand Down
Loading

0 comments on commit 5999a76

Please sign in to comment.