Skip to content

Commit

Permalink
Merge pull request #27 from PDOK/highlight_suggest
Browse files Browse the repository at this point in the history
Highlight suggest
  • Loading branch information
gerdos82 authored Jan 16, 2025
2 parents 5999a76 + 15e15cf commit 00209bf
Show file tree
Hide file tree
Showing 7 changed files with 55 additions and 51 deletions.
1 change: 1 addition & 0 deletions internal/etl/testdata/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ collections:
displayNameTemplate: "{{ .component_thoroughfarename }} - {{ .component_addressareaname | firstupper }}"
etl:
suggestTemplates:
- "{{ .component_thoroughfarename }} {{ .component_addressareaname }}"
- "{{ .component_thoroughfarename }} {{ .component_addressareaname }}"
- "{{ .component_thoroughfarename }}, {{ .component_postaldescriptor }} {{ .component_addressareaname }}"
ogcCollections:
Expand Down
3 changes: 3 additions & 0 deletions internal/etl/transform/transform.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"bytes"
"errors"
"fmt"
"slices"
"strconv"
"strings"
"text/template"
Expand Down Expand Up @@ -64,6 +65,8 @@ func (t Transformer) Transform(records []RawRecord, collection config.GeoSpatial
suggestions = append(suggestions, suggestion)
}
}
suggestions = slices.Compact(suggestions)

bbox, err := r.transformBbox()
if err != nil {
return nil, err
Expand Down
2 changes: 1 addition & 1 deletion internal/search/datasources/postgres/postgres.go
Original file line number Diff line number Diff line change
Expand Up @@ -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('simple', display_name, (select query from query)) as highlighted_text
ts_headline('simple', suggest, (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
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"collectionId": "buildings",
"collectionVersion": "1",
"displayName": "Abbewaal - Den Burg 1",
"highlight": "Abbewaal - <b>Den</b> Burg 1",
"highlight": "abbewaal <b>den</b> burg",
"href": "https://example.com/ogc/v1/collections/buildings/items/51?f=json",
"score": 0.07213475555181503
},
Expand Down Expand Up @@ -65,7 +65,7 @@
"collectionId": "buildings",
"collectionVersion": "1",
"displayName": "Abbewaal - Den Burg 1",
"highlight": "Abbewaal - <b>Den</b> Burg 1",
"highlight": "abbewaal <b>den</b> burg",
"href": "https://example.com/ogc/v1/collections/buildings/items/52?f=json",
"score": 0.07213475555181503
},
Expand Down Expand Up @@ -113,7 +113,7 @@
"collectionId": "buildings",
"collectionVersion": "1",
"displayName": "Abbewaal - Den Burg 10",
"highlight": "Abbewaal - <b>Den</b> Burg 10",
"highlight": "abbewaal <b>den</b> burg",
"href": "https://example.com/ogc/v1/collections/buildings/items/32183?f=json",
"score": 0.07213475555181503
},
Expand Down Expand Up @@ -161,7 +161,7 @@
"collectionId": "buildings",
"collectionVersion": "1",
"displayName": "Abbewaal - Den Burg 10",
"highlight": "Abbewaal - <b>Den</b> Burg 10",
"highlight": "abbewaal <b>den</b> burg",
"href": "https://example.com/ogc/v1/collections/buildings/items/53?f=json",
"score": 0.07213475555181503
},
Expand Down Expand Up @@ -209,7 +209,7 @@
"collectionId": "buildings",
"collectionVersion": "1",
"displayName": "Abbewaal - Den Burg 10",
"highlight": "Abbewaal - <b>Den</b> Burg 10",
"highlight": "abbewaal <b>den</b> burg",
"href": "https://example.com/ogc/v1/collections/buildings/items/32184?f=json",
"score": 0.07213475555181503
},
Expand Down Expand Up @@ -257,7 +257,7 @@
"collectionId": "buildings",
"collectionVersion": "1",
"displayName": "Abbewaal - Den Burg 10",
"highlight": "Abbewaal - <b>Den</b> Burg 10",
"highlight": "abbewaal <b>den</b> burg",
"href": "https://example.com/ogc/v1/collections/buildings/items/54?f=json",
"score": 0.07213475555181503
},
Expand Down Expand Up @@ -305,7 +305,7 @@
"collectionId": "buildings",
"collectionVersion": "1",
"displayName": "Abbewaal - Den Burg 11",
"highlight": "Abbewaal - <b>Den</b> Burg 11",
"highlight": "abbewaal <b>den</b> burg",
"href": "https://example.com/ogc/v1/collections/buildings/items/22549?f=json",
"score": 0.07213475555181503
},
Expand Down Expand Up @@ -353,7 +353,7 @@
"collectionId": "buildings",
"collectionVersion": "1",
"displayName": "Abbewaal - Den Burg 13",
"highlight": "Abbewaal - <b>Den</b> Burg 13",
"highlight": "abbewaal <b>den</b> burg",
"href": "https://example.com/ogc/v1/collections/buildings/items/56?f=json",
"score": 0.07213475555181503
},
Expand Down Expand Up @@ -401,7 +401,7 @@
"collectionId": "buildings",
"collectionVersion": "1",
"displayName": "Abbewaal - Den Burg 13",
"highlight": "Abbewaal - <b>Den</b> Burg 13",
"highlight": "abbewaal <b>den</b> burg",
"href": "https://example.com/ogc/v1/collections/buildings/items/55?f=json",
"score": 0.07213475555181503
},
Expand Down Expand Up @@ -449,7 +449,7 @@
"collectionId": "buildings",
"collectionVersion": "1",
"displayName": "Abbewaal - Den Burg 15",
"highlight": "Abbewaal - <b>Den</b> Burg 15",
"highlight": "abbewaal <b>den</b> burg",
"href": "https://example.com/ogc/v1/collections/buildings/items/57?f=json",
"score": 0.07213475555181503
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"collectionId": "buildings",
"collectionVersion": "1",
"displayName": "Abbewaal - Den Burg 1",
"highlight": "Abbewaal - <b>Den</b> Burg 1",
"highlight": "abbewaal <b>den</b> burg",
"href": "https://example.com/ogc/v1/collections/buildings/items/51?f=json",
"score": 0.07213475555181503
},
Expand Down Expand Up @@ -65,7 +65,7 @@
"collectionId": "buildings",
"collectionVersion": "1",
"displayName": "Abbewaal - Den Burg 1",
"highlight": "Abbewaal - <b>Den</b> Burg 1",
"highlight": "abbewaal <b>den</b> burg",
"href": "https://example.com/ogc/v1/collections/buildings/items/52?f=json",
"score": 0.07213475555181503
},
Expand Down Expand Up @@ -113,7 +113,7 @@
"collectionId": "buildings",
"collectionVersion": "1",
"displayName": "Abbewaal - Den Burg 10",
"highlight": "Abbewaal - <b>Den</b> Burg 10",
"highlight": "abbewaal <b>den</b> burg",
"href": "https://example.com/ogc/v1/collections/buildings/items/32183?f=json",
"score": 0.07213475555181503
},
Expand Down Expand Up @@ -161,7 +161,7 @@
"collectionId": "buildings",
"collectionVersion": "1",
"displayName": "Abbewaal - Den Burg 10",
"highlight": "Abbewaal - <b>Den</b> Burg 10",
"highlight": "abbewaal <b>den</b> burg",
"href": "https://example.com/ogc/v1/collections/buildings/items/53?f=json",
"score": 0.07213475555181503
},
Expand Down Expand Up @@ -209,7 +209,7 @@
"collectionId": "buildings",
"collectionVersion": "1",
"displayName": "Abbewaal - Den Burg 10",
"highlight": "Abbewaal - <b>Den</b> Burg 10",
"highlight": "abbewaal <b>den</b> burg",
"href": "https://example.com/ogc/v1/collections/buildings/items/32184?f=json",
"score": 0.07213475555181503
},
Expand Down Expand Up @@ -257,7 +257,7 @@
"collectionId": "buildings",
"collectionVersion": "1",
"displayName": "Abbewaal - Den Burg 10",
"highlight": "Abbewaal - <b>Den</b> Burg 10",
"highlight": "abbewaal <b>den</b> burg",
"href": "https://example.com/ogc/v1/collections/buildings/items/54?f=json",
"score": 0.07213475555181503
},
Expand Down Expand Up @@ -305,7 +305,7 @@
"collectionId": "buildings",
"collectionVersion": "1",
"displayName": "Abbewaal - Den Burg 11",
"highlight": "Abbewaal - <b>Den</b> Burg 11",
"highlight": "abbewaal <b>den</b> burg",
"href": "https://example.com/ogc/v1/collections/buildings/items/22549?f=json",
"score": 0.07213475555181503
},
Expand Down Expand Up @@ -353,7 +353,7 @@
"collectionId": "buildings",
"collectionVersion": "1",
"displayName": "Abbewaal - Den Burg 13",
"highlight": "Abbewaal - <b>Den</b> Burg 13",
"highlight": "abbewaal <b>den</b> burg",
"href": "https://example.com/ogc/v1/collections/buildings/items/56?f=json",
"score": 0.07213475555181503
},
Expand Down Expand Up @@ -401,7 +401,7 @@
"collectionId": "buildings",
"collectionVersion": "1",
"displayName": "Abbewaal - Den Burg 13",
"highlight": "Abbewaal - <b>Den</b> Burg 13",
"highlight": "abbewaal <b>den</b> burg",
"href": "https://example.com/ogc/v1/collections/buildings/items/55?f=json",
"score": 0.07213475555181503
},
Expand Down Expand Up @@ -449,7 +449,7 @@
"collectionId": "buildings",
"collectionVersion": "1",
"displayName": "Abbewaal - Den Burg 15",
"highlight": "Abbewaal - <b>Den</b> Burg 15",
"highlight": "abbewaal <b>den</b> burg",
"href": "https://example.com/ogc/v1/collections/buildings/items/57?f=json",
"score": 0.07213475555181503
},
Expand Down Expand Up @@ -497,7 +497,7 @@
"collectionId": "buildings",
"collectionVersion": "1",
"displayName": "Abbewaal - Den Burg 15",
"highlight": "Abbewaal - <b>Den</b> Burg 15",
"highlight": "abbewaal <b>den</b> burg",
"href": "https://example.com/ogc/v1/collections/buildings/items/58?f=json",
"score": 0.07213475555181503
},
Expand Down Expand Up @@ -545,7 +545,7 @@
"collectionId": "buildings",
"collectionVersion": "1",
"displayName": "Abbewaal - Den Burg 17",
"highlight": "Abbewaal - <b>Den</b> Burg 17",
"highlight": "abbewaal <b>den</b> burg",
"href": "https://example.com/ogc/v1/collections/buildings/items/16128?f=json",
"score": 0.07213475555181503
},
Expand Down Expand Up @@ -593,7 +593,7 @@
"collectionId": "buildings",
"collectionVersion": "1",
"displayName": "Abbewaal - Den Burg 19",
"highlight": "Abbewaal - <b>Den</b> Burg 19",
"highlight": "abbewaal <b>den</b> burg",
"href": "https://example.com/ogc/v1/collections/buildings/items/59?f=json",
"score": 0.07213475555181503
},
Expand Down Expand Up @@ -641,7 +641,7 @@
"collectionId": "buildings",
"collectionVersion": "1",
"displayName": "Abbewaal - Den Burg 19 A",
"highlight": "Abbewaal - <b>Den</b> Burg 19 A",
"highlight": "abbewaal <b>den</b> burg",
"href": "https://example.com/ogc/v1/collections/buildings/items/23322?f=json",
"score": 0.07213475555181503
},
Expand Down Expand Up @@ -689,7 +689,7 @@
"collectionId": "buildings",
"collectionVersion": "1",
"displayName": "Abbewaal - Den Burg 2",
"highlight": "Abbewaal - <b>Den</b> Burg 2",
"highlight": "abbewaal <b>den</b> burg",
"href": "https://example.com/ogc/v1/collections/buildings/items/16129?f=json",
"score": 0.07213475555181503
},
Expand Down Expand Up @@ -737,7 +737,7 @@
"collectionId": "buildings",
"collectionVersion": "1",
"displayName": "Abbewaal - Den Burg 2",
"highlight": "Abbewaal - <b>Den</b> Burg 2",
"highlight": "abbewaal <b>den</b> burg",
"href": "https://example.com/ogc/v1/collections/buildings/items/16130?f=json",
"score": 0.07213475555181503
},
Expand Down Expand Up @@ -785,7 +785,7 @@
"collectionId": "buildings",
"collectionVersion": "1",
"displayName": "Abbewaal - Den Burg 21",
"highlight": "Abbewaal - <b>Den</b> Burg 21",
"highlight": "abbewaal <b>den</b> burg",
"href": "https://example.com/ogc/v1/collections/buildings/items/60?f=json",
"score": 0.07213475555181503
},
Expand Down Expand Up @@ -833,7 +833,7 @@
"collectionId": "buildings",
"collectionVersion": "1",
"displayName": "Abbewaal - Den Burg 21 A",
"highlight": "Abbewaal - <b>Den</b> Burg 21 A",
"highlight": "abbewaal <b>den</b> burg",
"href": "https://example.com/ogc/v1/collections/buildings/items/61?f=json",
"score": 0.07213475555181503
},
Expand Down Expand Up @@ -881,7 +881,7 @@
"collectionId": "buildings",
"collectionVersion": "1",
"displayName": "Abbewaal - Den Burg 23",
"highlight": "Abbewaal - <b>Den</b> Burg 23",
"highlight": "abbewaal <b>den</b> burg",
"href": "https://example.com/ogc/v1/collections/buildings/items/16132?f=json",
"score": 0.07213475555181503
},
Expand Down Expand Up @@ -929,7 +929,7 @@
"collectionId": "buildings",
"collectionVersion": "1",
"displayName": "Abbewaal - Den Burg 23",
"highlight": "Abbewaal - <b>Den</b> Burg 23",
"highlight": "abbewaal <b>den</b> burg",
"href": "https://example.com/ogc/v1/collections/buildings/items/16131?f=json",
"score": 0.07213475555181503
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"collectionId": "addresses",
"collectionVersion": "1",
"displayName": "Abbewaal - Den Burg 1",
"highlight": "Abbewaal - <b>Den</b> Burg 1",
"highlight": "abbewaal <b>den</b> burg",
"href": "https://example.com/ogc/v1/collections/addresses/items/51?f=json",
"score": 0.07213475555181503
},
Expand Down Expand Up @@ -65,7 +65,7 @@
"collectionId": "addresses",
"collectionVersion": "1",
"displayName": "Abbewaal - Den Burg 1",
"highlight": "Abbewaal - <b>Den</b> Burg 1",
"highlight": "abbewaal <b>den</b> burg",
"href": "https://example.com/ogc/v1/collections/addresses/items/52?f=json",
"score": 0.07213475555181503
},
Expand Down Expand Up @@ -113,7 +113,7 @@
"collectionId": "addresses",
"collectionVersion": "1",
"displayName": "Abbewaal - Den Burg 10",
"highlight": "Abbewaal - <b>Den</b> Burg 10",
"highlight": "abbewaal <b>den</b> burg",
"href": "https://example.com/ogc/v1/collections/addresses/items/32183?f=json",
"score": 0.07213475555181503
},
Expand Down Expand Up @@ -161,7 +161,7 @@
"collectionId": "addresses",
"collectionVersion": "1",
"displayName": "Abbewaal - Den Burg 10",
"highlight": "Abbewaal - <b>Den</b> Burg 10",
"highlight": "abbewaal <b>den</b> burg",
"href": "https://example.com/ogc/v1/collections/addresses/items/53?f=json",
"score": 0.07213475555181503
},
Expand Down Expand Up @@ -209,7 +209,7 @@
"collectionId": "addresses",
"collectionVersion": "1",
"displayName": "Abbewaal - Den Burg 10",
"highlight": "Abbewaal - <b>Den</b> Burg 10",
"highlight": "abbewaal <b>den</b> burg",
"href": "https://example.com/ogc/v1/collections/addresses/items/32184?f=json",
"score": 0.07213475555181503
},
Expand Down Expand Up @@ -257,7 +257,7 @@
"collectionId": "addresses",
"collectionVersion": "1",
"displayName": "Abbewaal - Den Burg 10",
"highlight": "Abbewaal - <b>Den</b> Burg 10",
"highlight": "abbewaal <b>den</b> burg",
"href": "https://example.com/ogc/v1/collections/addresses/items/54?f=json",
"score": 0.07213475555181503
},
Expand Down Expand Up @@ -305,7 +305,7 @@
"collectionId": "addresses",
"collectionVersion": "1",
"displayName": "Abbewaal - Den Burg 11",
"highlight": "Abbewaal - <b>Den</b> Burg 11",
"highlight": "abbewaal <b>den</b> burg",
"href": "https://example.com/ogc/v1/collections/addresses/items/22549?f=json",
"score": 0.07213475555181503
},
Expand Down Expand Up @@ -353,7 +353,7 @@
"collectionId": "addresses",
"collectionVersion": "1",
"displayName": "Abbewaal - Den Burg 13",
"highlight": "Abbewaal - <b>Den</b> Burg 13",
"highlight": "abbewaal <b>den</b> burg",
"href": "https://example.com/ogc/v1/collections/addresses/items/56?f=json",
"score": 0.07213475555181503
},
Expand Down Expand Up @@ -401,7 +401,7 @@
"collectionId": "addresses",
"collectionVersion": "1",
"displayName": "Abbewaal - Den Burg 13",
"highlight": "Abbewaal - <b>Den</b> Burg 13",
"highlight": "abbewaal <b>den</b> burg",
"href": "https://example.com/ogc/v1/collections/addresses/items/55?f=json",
"score": 0.07213475555181503
},
Expand Down Expand Up @@ -449,7 +449,7 @@
"collectionId": "addresses",
"collectionVersion": "1",
"displayName": "Abbewaal - Den Burg 15",
"highlight": "Abbewaal - <b>Den</b> Burg 15",
"highlight": "abbewaal <b>den</b> burg",
"href": "https://example.com/ogc/v1/collections/addresses/items/57?f=json",
"score": 0.07213475555181503
},
Expand Down
Loading

0 comments on commit 00209bf

Please sign in to comment.