Tech Blog

Creating Complex Sets with the Alma API

The Alma configuration and administration APIs are quite powerful and enable advanced orchestration workflows. We’ve shown how to use the APIs in previous blog posts. In this post, we will show how to use the create set API to create a complex logical set with multiple conditions.

The Developer Network contains documentation on the logical set query syntax, including a reference for all of the available search indexes. However, for complex queries it can be easier to use the Alma user interface to craft the set, and then use the retrieve set API to view the syntax.

In this example, we wish to create a set of physical titles which have holdings in a specified call number range and in one of several physical locations. First, we craft the query in Alma’s advanced search screen:

Once I’m happy with the results, I can click the “Save Query” button.

Now I can view the details of the newly created set to retrieve the set ID.

Next I use the retrieve set API to retrieve the set and look at the query.value attribute.

{
  ...
  "query": {
    "value": "IEP where HOLDING ((permanentCallNumberType OUTER_EQUAL \"0\") AND HOLDING (PermanentCallNumber GREATER_EQUAL \"AC\") AND HOLDING (PermanentCallNumber LESS_THAN \"AZ\") AND HOLDING (permanentPhysicalLocation EQUAL ((MAIN : main) or (GRAD : grad))))",
    "desc": "where (Permanent call number type equals \"Library of Congress classification\" AND Permanent call number >= \"AC\" AND Permanent call number < \"AZ\" AND Library (Holdings) contains phrase ((Graduate Library : Main Stacks) or (Main Library : Main)))"
  }
}

Once I have the syntax, it’s simple to make changes to the query in the existing set or to create a new set. For example, if I want to run the same query different locations, I can change the location section of the query and submit a POST request for a new set (or a PUT to update the existing set).

{
    "name": "Set API Blog - POST New Set",
    "type": {
        "value": "LOGICAL"
    },
    "content": {
        "value": "IEP"
    },
    "private": {
        "value": "false"
    },
    "query": {
        "value": "IEP where HOLDING ((permanentCallNumberType OUTER_EQUAL \"0\") AND HOLDING (PermanentCallNumber GREATER_EQUAL \"AC\") AND HOLDING (PermanentCallNumber LESS_THAN \"AZ\") AND HOLDING (permanentPhysicalLocation EQUAL ((MAIN : STACK) or (GRAD : gradmedia))))"
    }
}

Using this approach, you can leverage these APIs to introduce more automation to your library processes.

Leave a Reply