Skip to content

Commit

Permalink
Merge pull request #102 from hbz/101-customGndSuggest
Browse files Browse the repository at this point in the history
Custom autosuggest post
  • Loading branch information
acka47 authored Jun 24, 2024
2 parents 6a459ee + 719070d commit 40efe59
Show file tree
Hide file tree
Showing 5 changed files with 77 additions and 1 deletion.
2 changes: 2 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@ source 'https://rubygems.org'
gem 'github-pages', group: :jekyll_plugins
gem 'jekyll-seo-tag'
gem "webrick", "~> 1.8"
# See https://github.com/ffi/ffi/issues/1103
gem "ffi", "< 1.17.0"
2 changes: 1 addition & 1 deletion README.textile
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Quick setup:

Start server locally when working on a draft:

@bundle exec jekyll serve --drafts --watch@
@bundle exec jekyll serve --drafts --future --watch@

Open "http://localhost:4000":http://localhost:4000

Expand Down
73 changes: 73 additions & 0 deletions _posts/2024-06-24-custom-gnd-suggests.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
---
layout: post
title: "Customize your GND autosuggests"
date: 2024-06-24
author: Adrian Pohl
tags: lobid-gnd
---

Recently, the current lookup options in lobid-gnd turned out to not be enough for a use case we were facing. We needed to associate date and place of a person's birth/death but couldn't. So we added this option for everyone to benefit from. Now, you can get auto-suggests for GND persons that include a good overview of birth/death dates and places, occupations/professions and places of activity. They might for example look like this:

![Suggest list of different persons for query 'rowohlt' containing the named information with unicode icons fr birth and death](/images/20240624-custom-gnd-suggests/rpb-strapi-screenshot.png)

### How do I make lobid return a custom autosuggest format?

We have documented the configuration of such a customized GND autosuggest string in the [API documentation](https://lobid.org/gnd/api#auto-complete).

For example, here is the query that returns autosuggestions like the above: [`rowohlt+AND+type:Person&format=json:preferredName,*_dateOfBirth+_placeOfBirth,†_dateOfDeath+_placeOfDeath,placeOfActivity,professionOrOccupation`](https://lobid.org/gnd/search?q=rowohlt+AND+type:Person&format=json%3ApreferredName,*_dateOfBirth+_placeOfBirth,%E2%80%A0_dateOfDeath+_placeOfDeath,placeOfActivity,professionOrOccupation)

The reponse to this query looks like this:

```json
[ {
"label" : "Rowohlt, Hilda | † 1943",
"id" : "https://d-nb.info/gnd/116004595X",
"category" : "Individualisierte Person"
}, {
"label" : "Rowohlt, Charlotta | Schauspielerin",
"id" : "https://d-nb.info/gnd/124750848X",
"category" : "Individualisierte Person"
}, {
"label" : "Rowohlt, Heinrich",
"id" : "https://d-nb.info/gnd/139303960",
"category" : "Individualisierte Person"
}, {
"image" : "https://commons.wikimedia.org/wiki/Special:FilePath/HARRYROW.jpg?width=100",
"label" : "Rowohlt, Harry | * 1945 Hamburg | † 2015 Hamburg | Schriftsteller; Lyriker; Verleger; Journalist; Sprecher; Übersetzer",
"id" : "https://d-nb.info/gnd/107828553",
"category" : "Individualisierte Person"
}, {
"label" : "Rowohlt, Hilde",
"id" : "https://d-nb.info/gnd/116667230",
"category" : "Individualisierte Person"
}, {
"label" : "Rowohlt, Ernst | * 1887 Bremen | † 1960 Hamburg | Leipzig; Berlin | Verleger",
"id" : "https://d-nb.info/gnd/118603493",
"category" : "Individualisierte Person"
}, {
"label" : "Pierenkämper-Rowohlt, Maria | * 1910 | † 2005 | Hamburg-Volksdorf | Schauspielerin",
"id" : "https://d-nb.info/gnd/116184620",
"category" : "Individualisierte Person"
}, {
"label" : "Ledig-Rowohlt, Heinrich Maria | * 1908 Leipzig | † 1992 Delhi | Verleger",
"id" : "https://d-nb.info/gnd/118570757",
"category" : "Individualisierte Person"
}, {
"label" : "Ledig-Rowohlt, Jane | † 1994 | Hamburg",
"id" : "https://d-nb.info/gnd/116853166",
"category" : "Individualisierte Person"
}, {
"label" : "Pierenkämpfer, Maria | * [19XX] | Schauspielerin",
"id" : "https://d-nb.info/gnd/1329213513",
"category" : "Individualisierte Person"
} ]
```

Basically, as with autosuggest queries before, you have to configure the response payload by using the `format=json` parameter, add a trailing colon and then the configuration bit which in our case is `preferredName,*_dateOfBirth+_placeOfBirth,†_dateOfDeath+_placeOfDeath,placeOfActivity,professionOrOccupation`.

As usual, you have a comma-seperated list of all the field contents you want to be returned. The additional option is provided by allowing to use `_{field}` with the addition of custom characters like "†". I could also use "born in"/"died in" instead, like this: [`preferredName,born in_dateOfBirth,placeOfBirth,died in_dateOfDeath,placeOfDeath,placeOfActivity,professionOrOccupation`](https://lobid.org/gnd/search?q=rowohlt+AND+type:Person&format=json%3ApreferredName,born in_dateOfBirth,placeOfBirth,died in_dateOfDeath,placeOfDeath,placeOfActivity,professionOrOccupation)

We hope that others will also benefit from this option. Let us know if you like it.


*This feature was added in the context of a project where we are building a new editorial backend for the regional bibliography and person database of Rhineland-Palatinate ([RPB](https://rpb.lbz-rlp.de/) &amp; [RPPD](https://rppd.lobid.org)). For looking up GND IDs in the [Strapi](https://strapi.io/)-based editorial backend, we are relying on the lobid-gnd API. We were happy to play back the needed improvements for the lookups into the lobid-gnd service.*
1 change: 1 addition & 0 deletions css/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ code {
padding: 2px 4px;
background-color: #f5f5f5;
font-size: smaller;
word-wrap: break-word;
}

img {
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 40efe59

Please sign in to comment.