[Archivesspace_Users_Group] ArchivesSpace API questions

Mayo, Dave dave_mayo at harvard.edu
Tue Feb 18 09:02:56 EST 2020


You can use the ‘q’ parameter in a search, also, which uses Solr syntax – the following is how one would search via ArchivesSnake for a resource with the EAD ‘hou00001’:

client.get('search', params={"q": 'ead_id:hua00001 AND primary_type:resource', 'page':1})

Fuller example:

client = asnake.client.ASnakeClient
resp = client.get('search', params={"q": 'ead_id:hua00001 AND primary_type:resource', 'page':1})
If resp.status_code == 200:
    results = resp.json()[‘results’]
    If len(results) == 1:
        record = results[0]
    else:
        # got 0 or more than one result, weird, handle errors here

Solr query syntax is per: http://lucene.apache.org/core/4_0_0/queryparser/org/apache/lucene/queryparser/classic/package-summary.html

Basically, it’s FIELD:SEARCH_STRING, AND and OR have the regular Boolean meanings.  For this query in particular, you probably could leave off “AND primary_type:resource” since only resources have ead_id fields with values in them.

--
Dave Mayo (he/him)
Senior Digital Library Software Engineer
Harvard University > HUIT > LTS

From: <archivesspace_users_group-bounces at lyralists.lyrasis.org> on behalf of Noah Huffman <noah.huffman at duke.edu>
Reply-To: Archivesspace Users Group <Archivesspace_Users_Group at lyralists.lyrasis.org>
Date: Monday, February 17, 2020 at 11:00 AM
To: Archivesspace Users Group <Archivesspace_Users_Group at lyralists.lyrasis.org>
Subject: Re: [Archivesspace_Users_Group] ArchivesSpace API questions

Hi Alan,

You could do an advanced search via the API to target the EADID values in resource records.  Forming advanced queries isn’t well documented (there are some old posts on the list with examples), but here’s an example for querying the EADID field:

https://github.com/duke-libraries/archivesspace-duke-scripts/blob/master/python/asEADpublish_and_export_eadid_input.py#L40<https://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_duke-2Dlibraries_archivesspace-2Dduke-2Dscripts_blob_master_python_asEADpublish-5Fand-5Fexport-5Feadid-5Finput.py-23L40&d=DwMFAg&c=WO-RGvefibhHBZq3fL85hQ&r=_Mv1dY22K7jvT5MD7xjbvGVzRDOUMhx4WYcnPSIzYnE&m=Eg9s_yESQgbf5pOadeLq5LA2ndLxhbH8YwRUYaszVxY&s=LEBkbpqOcmej9UcNPusEeXxuE1uu80z4WQGp8ttifyE&e=>

With the above query, the API will return a result set (not an individual resource record), but assuming your EADIDs are unique, the target resource record should always be your first result.

-Noah

================
Noah Huffman
Archivist for Metadata, Systems, and Digital Records
David M. Rubenstein Rare Book & Manuscript Library
Duke University | 919-660-5982
http://library.duke.edu/rubenstein/<https://urldefense.proofpoint.com/v2/url?u=http-3A__library.duke.edu_rubenstein_&d=DwMFAg&c=WO-RGvefibhHBZq3fL85hQ&r=_Mv1dY22K7jvT5MD7xjbvGVzRDOUMhx4WYcnPSIzYnE&m=Eg9s_yESQgbf5pOadeLq5LA2ndLxhbH8YwRUYaszVxY&s=kNISDddsY05DGTMHd8Q4gbBYN7pVxD8_fS_Zz2qCYy4&e=>
Pronouns: he / him / his





From: archivesspace_users_group-bounces at lyralists.lyrasis.org <archivesspace_users_group-bounces at lyralists.lyrasis.org> On Behalf Of Huebschen, Alan M
Sent: Monday, February 17, 2020 10:03 AM
To: Archivesspace Users Group <Archivesspace_Users_Group at lyralists.lyrasis.org>
Subject: [Archivesspace_Users_Group] ArchivesSpace API questions


Hi all,



I've been working on a project to remigrate our original database from Archon to ArchivesSpace due to some top container issues in the first migration we ran. After our initial migration, changes were made in ArchivesSpace and those changes would not be present in the new migration. In an attempt to merge the changes from our old ASpace db to the new one, I've been working with the ArchivesSpace API via ArchivesSnake to pull JSON copies of any record that was modified after the original migration. My goal is to import these modified records to the newly migrated db, but I seem to have run into a problem.



After remigrating, it looks like the IDs of records have changed so it isn't as easy as deleting the unmodified record from the new migration and importing the modified JSON because their IDs do not match up. From what I saw in the ArchivesSnake and ASpace API docs, it appears that the only way to refer to a record is with that ID. Are there any other ways I can compare records through the API or am I stuck using the ID?



The only way I have been able to compare records to each other and find the new ID of the modified record is to iterate over all records in a specific category for each and every one of the records I am attempting to upload. This takes an incredibly long time. Theoretically I think I can load all IDs and records into local memory to iterate over rather than querying the ASpace API and this should speed up the process but I was wondering if anyone knew of a better way to accomplish this such as using EAD ID rather than ID through the API.



Thank you,



-Alan Huebschen

Brookens Library Information Systems

University of Illinois at Springfield
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lyralists.lyrasis.org/pipermail/archivesspace_users_group/attachments/20200218/a4a362f1/attachment.html>


More information about the Archivesspace_Users_Group mailing list