-
Notifications
You must be signed in to change notification settings - Fork 1
Search API examples
The BDR Search API is based on Solr, one of the two most popular indexers in the world, so many developers will be familiar with it, and there are many online resources for how to structure queries (one example-resource). It doesn't support all of Solr's query features, but does support many useful ones. In general, the search query should be formatted the same way as standard Solr queries.
If the query is badly formatted, a ‘400 / Bad Request’ response will be returned.
If the search is successful (even if there are no results), a ‘200 / OK’ response will be returned.
https://repository.library.brown.edu/api/search/?[ search-query ]
- Example: https://repository.library.brown.edu/api/search/?q=primary_title:irish&rows=25 Note that although over 100 results are found, only 25 are returned
-
Query on title with row-definition
- url: https://repository.library.brown.edu/api/search/?q=primary_title:irish&rows=25
- note that although over 100 results are found, only 25 are returned
- note that each result shows some 50+ elements of each result. Let's say you really only wanted a link to the item-id,title, and description. You could get those filtered results via: https://repository.library.brown.edu/api/search/?q=primary_title:irish&rows=25&fl=pid,primary_title,abstract
- added
&fl=pid,primary_title,abstract
- added
- and to get to the next 25: https://repository.library.brown.edu/api/search/?q=primary_title:irish&rows=25&fl=pid,primary_title,abstract&start=25
- added
&start=25(0 through 24 were the first 25)
- added
-
Find items in a collection, only returning title and pid
- url: https://repository.library.brown.edu/api/search/?q=rel_is_member_of_collection_ssim:%22bdr:wum3gm43%22&fl=primary_title,pid
- sometimes can provide more flexibility to specify the data returned than using the collections-api.
-
Find items in a collection where the title does NOT contain the word 'Page'
- url: https://repository.library.brown.edu/api/search/?q=rel_is_member_of_collection_ssim:%22bdr:wum3gm43%22%20AND%20-primary_title:*Page*&fl=primary_title,pid
- specifies that only the
primary_titleandpidfields are returned.
-
Find items in a collection for those items that are NOT part of another collection
-
Real world example where I wanted to find hall-hoag org-items that didn't have a particular data-element
- url-human:
https://repository.library.brown.edu/api/search/?q=rel_is_member_of_collection_ssim:"bdr:wum3gm43" AND -mods_record_info_note_hallhoagorglevelrecord_ssim:"Organization Record" AND -rel_is_part_of_ssim:* - url encoded and usable: https://repository.library.brown.edu/api/search/?q=rel_is_member_of_collection_ssim:%22bdr:wum3gm43%22%20AND%20%20-mods_record_info_note_hallhoagorglevelrecord_ssim:%22Organization%20Record%22%20AND%20-rel_is_part_of_ssim:*
- explanation:
- is member of hall-hoag collection
- does not have a particular record-info-note data-element
- is not part-of another object
- note: once I add the data-element, the url will return zero items -- this is just a documentation example of how the apis can be useful to find records in need of data-cleanup.
- url-human: