[Archivesspace_Users_Group] Advanced Search for API

Chris Fitzpatrick Chris.Fitzpatrick at lyrasis.org
Mon May 18 06:45:20 EDT 2015


Hi Steelsen,


Yes, so for advanced queries, you pass in a jsonmodel advanced_query object ( https://github.com/archivesspace/archivesspace/blob/master/common/schemas/advanced_query.rb )


 This  object has a property "query" that can be a boolean_query ( https://github.com/archivesspace/archivesspace/blob/master/common/schemas/boolean_query.rb)<https://github.com/archivesspace/archivesspace/blob/master/common/schemas/boolean_query.rb> boolean_field_query ( https://github.com/archivesspace/archivesspace/blob/master/common/schemas/boolean_field_query.rb ) date_field_query ( https://github.com/archivesspace/archivesspace/blob/master/common/schemas/date_field_query.rb ) or a field_query ( https://github.com/archivesspace/archivesspace/blob/master/common/schemas/field_query.rb )



So, a queries could look like this:


boolean query ( keyword 'My Awesome Search Term' and 'AND'  published = true ) :

 "http://localhost:4567/repositories/2/search?page=1&aq={\"query\":{\"op\":\"AND\",\"subqueries\":[{\"field\":\"keyword\",\"value\":\"My Awesome Search Term\",\"jsonmodel_type\":\"field_query\",\"negated\":false,\"literal\":false},{\"field\":\"published\",\"value\":true,\"jsonmodel_type\":\"boolean_field_query\"}],\"jsonmodel_type\":\"boolean_query\"},\"jsonmodel_type\":\"advanced_query\"}"


boolean_field_query ( published = true ):

"http://localhost:4567/repositories/2/search?page=1&aq={\"query\":{\"field\":\"published\",\"value\":true,\"jsonmodel_type\":\"boolean_field_query\"},\"jsonmodel_type\":\"advanced_query\"}"


field query ( keyword for 'My Awesome Search Term') :

"http://localhost:4567/repositories/2/search?page=1&aq={\"query\":{\"field\":\"keyword\",\"value\":\"My Awesome Search Term\",\"jsonmodel_type\":\"field_query\",\"negated\":false,\"literal\":false}}


date_field_query  (  Created date after May 5 2015 ) :

 "http://localhost:4567/repositories/2/search?page=1&aq={\"query\":{\"field\":\"create_time\",\"value\":\"2015-05-05\",\"comparator\":\"greater_than\",\"jsonmodel_type\":\"date_field_query\"},\"jsonmodel_type\":\"advanced_query\"}"


 Does that help?


b,chris.






Chris Fitzpatrick | Developer, ArchivesSpace
Skype: chrisfitzpat  | Phone: 918.236.6048
http://archivesspace.org/
________________________________
From: archivesspace_users_group-bounces at lyralists.lyrasis.org <archivesspace_users_group-bounces at lyralists.lyrasis.org> on behalf of Smith, Steelsen <steelsen.smith at yale.edu>
Sent: Sunday, May 17, 2015 2:41 AM
To: Archivesspace Users Group
Subject: [Archivesspace_Users_Group] Advanced Search for API

Hi All,

The Rest API Endpoint repositories/:id/search indicates that there's an advanced search input that requires a json formatted "advanced search" in the URI. Does anyone have an example of what it might look like, or a field list of what can be searched for? I'm trying to perform some very specific searches and am finding myself pulling in a lot of extra information and working through it. A more general question, is there better API documentation somewhere than exists in the autodocs? Sample strings would save a lot of time from the trial and error process I'm using now.

Thanks,
Steelsen



___________________________
Steelsen Smith
Fulfillment Systems Specialist
Enterprise Systems Group
Yale Library IT
203.432.3333

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lyralists.lyrasis.org/pipermail/archivesspace_users_group/attachments/20150518/4ac36f60/attachment.html>


More information about the Archivesspace_Users_Group mailing list