1.11 Solr Queries

General

Again and again the backend of the Goobi viewer refers to the necessity of formulating solr queries when it comes to providing a functionality only for certain records. This page will answer some questions in this context.

Formulation of Solr queries

A Solr query is always formulated as FIELDNAME:VALUE, for example MD_PLACEPUBLISH:Berlin. If the value contains a space or other separator it must be enclosed in quotes MD_PLACEPUBLISH: "New York".

Several conditions can be written one after the other separated by spaces. These are automatically linked as OR.

Example

MD_PLACEPUBLISH:Berlin MD_PLACEPUBLISH:"New York"

The query means: "Find all hits where the field MD_PLACEPUBLISH contains the value Berlin or the value New York".

If conditions are to be linked with AND, then the field-value pair must be preceded by a + sign.

Example

+MD_AUTHOR: "John Doe" +MD_PLACEPUBLISH: "New York"

The query means: "Find all matches where the field MD_AUTHOR contains the value John Doe and the field MD_PLACEPUBLISH contains the value New York."

If conditions are to be negated, this is done with a prefixed - character.

Example

+MD_AUTHOR: "John Doe" -MD_PLACEPUBLISH:Washington

The query means: Find all matches in which the field MD_AUTHOR contains the value John Doe and at the same time the field MD_PLACEPUBLISH does not contain the value Washington.

Parenthesis substitution is also possible by specifying single parentheses. This can be used for combining AND and OR conditions.

Example

+ISWORK:true +DOCSTRCT:monograph +(FACET_PLACEPUBLISH:Berlin FACET_PLACEPUBLISH:'New York')

The query means: Find me all records of the publication type monograph which have either Berlin or New York as place of publication.

Finding out the Solr fields

For the formulation of the Solr queries it is necessary to know which Solr fields exist at all. Two sources of information are available for this. First, chapter 2.10 of the Goobi viewer Indexer documentation roughly explains the Solr schema:

Second, every Goobi viewer installation comes with an API endpoint where the existing Solr fields are listed including their translations. The endpoint can be reached at the URL /index/fields, for example here:

Last updated