Logic and background for Related works queries

There have been a few different tickets tackling the desired MVP logic for the Related works component and even more conversations around what we think should be queried. Because of the amount of people involved, we thought it best to document those decisions somewhere. It is likely to change and be improved upon.

Resources

Table of contents

The component gets added to a works page if the work has at least one subject label.

Current queries

The base of all queries lies with the subject labels. If a work does not have any subject labels, we don't query for the others at all, since their results would be too generic.

The queries are split into three categories:

  • Subject related

  • From the same century (date range) with similar subjects

  • Genres related, with similar subjects

For each query we fetch 4 works, because we want to display 3 and the work being viewed is likely to be returned as a result. We filter it out afterwards.

We query a maximum of three individual subjects, a date range if it can be determined and up to two genres. There can therefore be up of six queries made on each work page.

Up to three queries/tabs. Uses the first three subjects from the response array.

Query

  • pageSize: 4

  • includes: [production, contributor] - required for the display data we need for cards

  • subjects.label: one of the first three subject labels of the work

Date range

One query/tab Used for a "Century" tab, e.g. "From 1900s".

Queried if the date is a string made of four numbers.

Valid:

  • 1999

  • 1284

  • 1683

Not valid:

  • [1928]

  • 1937?

  • From 1930 to 1934

  • 1933-1954

If the string is valid, we then use it to get the century range.

Query

  • pageSize: 4

  • includes: [production, contributor]

  • subjects.label: the first three subject labels of the work

  • production.dates.from: First day of the century

  • production.dates.to: Last day of the century

Genres

Maximum of 2 genres/tabs, but only because we wanted to reduce the amount of total queries. The original request was for up to 3 tabs for genres.

We get the first two genres in the response array:genres?.map(genre => genre.label).slice(0, 2)

So up to two queries are done, by looping through the above's results:

Query

  • pageSize: 4

  • includes: [production, contributor]

  • subjects.label: the first three subject labels of the work

  • genres.label: The genre label

Interesting works to consider

We have found some related works results that made it clear more work would be required on the logic.

https://wellcomecollection.org/works/a2262ru9 https://wellcomecollection.org/works/a376cmj9

It's strange when one of the subject label is date related, because we then also have the century tab. That can be the same century or a different one, if the work is a modern one about a different century.

Same results

https://wellcomecollection.org/works/a22xvp3c

Many works will display the same results for most of their tabs. An answer would be to fetch more works and compare/filter them, but we chose not to do that at this stage.

Last updated