Difference between revisions of "SRU"

From swissbib
Jump to: navigation, search
Line 61: Line 61:
** example '''http://sru.swissbib.ch/sru/search/defaultdb?query=+dc.anywhere+%3D+hello+world&operation=searchRetrieve&recordSchema=info%3Asrw%2Fschema%2F1%2Fmarcxml-v1.1-light&maximumRecords=10&startRecord=0&recordPacking=XML'''
** example '''http://sru.swissbib.ch/sru/search/defaultdb?query=+dc.anywhere+%3D+hello+world&operation=searchRetrieve&recordSchema=info%3Asrw%2Fschema%2F1%2Fmarcxml-v1.1-light&maximumRecords=10&startRecord=0&recordPacking=XML'''
= Retrieve a lot of records with a cursor =
See here https://github.com/swissbib/sruServer/wiki/sru-cursor-model (based on SOLR cursors)
= Examples =
= Examples =
Line 75: Line 79:
= (Logical) Databases =
= (Logical) Databases =

Latest revision as of 16:42, 29 October 2018

Accessing the SRU-Service

The service is openly accessible under the following general URL:


  • The service is provided openly as long as the usage is fair.
  • Abuses of the service will result in restriction of usage.
  • Please inform us if you plan to access the SRU interface regularly as part of your search interface.
  • We can configure a logical database for your institution or project.
  • The impementation of the swissbib SRU server is freely available as Open Source.

SRU interface standards

The swissbib SRU service supports the SRU protocol: Version 1.1

Supported retrieval language is CQL: Version 1.1, Level 2

SRU functions

SRU incorporates the basic functions:

  • Explain: Self-description in XML standard format, including information about:
    • Database
    • Indices
    • Data formats
  • Search / Retrieve: Search query
    • Retrieval language: CQL (Common / Contextual Query Language)
    • Boolean operators (and, or, not) are supported

  • swissbib SRU is implemented as a REST service. Therefore the basic functions as described above are accessible as REST resources.
  • Beside the standard SRU functions swissbib provides an additional user interface function which enables users to explore the service and its content interactively.

Mandatory and additional parameters of the SRU functions (resources)

Retrieve a lot of records with a cursor

See here https://github.com/swissbib/sruServer/wiki/sru-cursor-model (based on SOLR cursors)


All books about creativity from the EPFL Library (code E02) which were published after 2010, result in Dublin Core Format :


All maps from libraries of the IDS Basel Bern network which are related to Biel, result in Marc Xml Format :


All documents which match "done allen" in all fields, result in JSON marc :


(Logical) Databases

  • swissbib SRU now provides the possibility to restrict the search on predefined databases
  • At the moment the following databases are supported:
  • Special databases are available using the REST style.
  • If you have special needs for your application let us know. Additional logical databases are easily implemented on the server side. Clients are released to consider such restrictions in the client code.
  • If the database specification is omitted in the request, the defaultdb is used

Available search fields SRU

Access Point Context Set Index Description
Format/Type of Material Dublin Core format swissbib-format code
Language Dublin Core language this means ISO 639-2 codes.
Possessing Institution Bath possessingInstitution Local Library code on a nice page and for download in json:
Possessing library network / union swissbib xNetwork Library codes of Swiss networks (see list)
Filter (for online ressources) swissbib xfilter Filter: Use value 'ONL' to get online resources. Example.
Filter (for CC0 metadata) swissbib xfilter Filter: the metadata of 85% of the records is in the public domain. However, 15% of the records are not in the public domain. To exclude these records, you need to exclude the value MDRR (metadata rights reserved) in the xfilter field (NOT MDRR in field dc.xfilter). Example

Supported CQL relations and how to use them

  • More information is available via the SRU explain operation.
  • Comparison relations such as < or <= or > or >= > are only useful for special indices with numeric values such as dc.date for the published date. If such relations are used in the context of non-numeric indices the default relation = is used
  • How to use the CQL relations
    • For simple term searches use the  =  relation.
    • Multiple terms within a subclause in combination with a  =  relation will be implicitly combined with the boolean AND operator.
    • To express the combination of terms in subclause with the AND operator, the ALL relation should be used.
    • Exact phrase searches will be defined by using the EXACT relation. Double quotes in terms are not necessary and will be filtered out by the parser.
    • To combine the search terms of a subclause with the logical OR operator use the ANY relation for a subclause.
    • Subclauses of a complete query can be combined with the boolean operators AND / OR or NOT.
  • the interactive form is thought as a guide for the use of the supported CQL queries

Record schemas

  • see explain operation for the special databases and the interactive form to play around with them

Additional options

  • Get Holdings: This allows detailed holding information per record to be retrieved (only for the MARC schema).

Further requirements

  • If your requirements need more functionality - please let us know. In general the functionality of Search Servers could be transformed into the SRU standard using the CQL query syntax. If such an effort is justified we could implement it. But as said above: The Search Server interface used by swissbib is also freely available so it could be used by any client for more complex queries and additional features such as facets, more like this, highlighting and much, much more .....
  • You can use directly the github issues list of the repository for notification


Recently I stumbled upon an alternative and nice SRU server implementation realized by Jörg Prante It's implemented as an Elasticsearch plugin. It is using JFlex for the parsing process instead of the cql-java library as it is done in our current implementation