Tech Blog

Linked Data Property Graphs in Discovery

In a previous blog post, we explored property graphs in the context of linked data in bibliographic records. In this post, we’ll experiment with exposing information from the graph DB to end users in discovery. Our goal is to add a section to the Primo full record display which shows other works by the same author. We’ll be using the Primo customization capabilities (“Open Discovery Framework“), specifically the “Altmetrics widget” recipe.

Building the Query

We’ve already added records to our graph in the previous post. Conceptually, we  have works, authors, and identifiers linked via  nodes and connectors as in the following graph:

Since we’d like to query our graph to find additional works by the same author, we build a Cypher query to look for links as follows:

  • Match a Book with the specified URI (book:Book {uri: "https://open-na.hosted.exlibrisgroup.com/alma/INST_CODE/bibs/MMS_ID"})
  • Connected to an author resource by a CREATED link (- [:CREATOR] -> (author:Resource))
  • Connected to other Books (<- [:CREATOR] - (other:Book))

We’ll also need the ISBN of the other works, so we perform a sub query to retrieve the first resource of type Isbn13 with an IDENTIFIER link.

The whole query looks as follows:

MATCH 
(book:Book {uri: "https://open-na.hosted.exlibrisgroup.com/alma/INST_CODE/bibs/MMS_ID"}) - [:CREATOR] -> (author:Resource) <- [:CREATOR] - (other:Book) 
CALL { 
  WITH other 
  MATCH (other) - [:IDENTIFIER] -> (isbn:Isbn13) 
  RETURN isbn LIMIT 1  
}  
RETURN other, isbn

When run in the Neo4J Browser, the query returns the following entities:

Using the Neo4J API

Neo4J provides an HTTP API which supports full query and update capabilities. Since we only want to query our data, we create a new user with a read-only role and use that user to access the API. We need to access the API from our Primo widget, so we’ll build a payload as expected by the HTTP API and then create a request for the AngularJS HTTP client:

Building the Primo Widget

Now we’re ready to build our widget for the full display page in Primo. Our widget will perform the following tasks:

  1. Query the Neo4J instance for other works
  2. Gather thumbnail images for the returned ISBNs from the Google Books API
  3. Add a new section to the full display which shows the related works along with the book cover and a link to search for the title in Primo

The result looks something like the following:

The full code is available in this Gist. Of course, this example just scratches the surface of what’s possible using the power of graph databases and linked data. Hopefully it whets the appetite of those who wish to explore further.

Leave a Reply