Solr GUI And Query Syntax#

In the next part we will take a closer look at the search GUI of Solr and its query syntax.

Access Solr GUI#

Solr is a REST-based wrapper around the Java lucene index. It comes with its own web GUI. It is possible to access all of the SOLR API via REST and most of this functionality is exposed via its web GUI. To test it out, do the following:

Solr Query Syntax#

After selecting the core, go to "Query". This form allows you to query the Solr index.

Solr Query Parameters:

Query "q":


A Solr response looks like this:

        "Description":"Site News",
        "SearchableText":"news  News  Site News ",

Filter Query "fq"

This parameter can be used to specify a query that restricts the superset of documents that can be returned without influencing the score.

It can be very useful for speeding up complex queries since the queries specified with fq are cached independently from the main query. Caching means the same filter is used again for a later query (i.e. there's a cache hit).

See SolrCaching to learn about the caches Solr uses:


Sorting "sort":

"Date asc"
"Date desc"

Filter List "fl":


This parameter can be used to specify a set of fields to return, limiting the amount of information in the response.

Response Writer "wt":


A Response Writer generates the formatted response of a search.

Solr Query Via URL#

Copy a query from the Solr GUI, e.g.:


You can use curl or the Python package requests ( to access the REST API of Solr.

Solr Query Via API#

Another way of accessing Solr is to use a Python wrapper, which exposes the Solr API in a Pythonic way.

collective.solr has included such a wrapper (, which is old but still works for our case. Meanwhile there are other packages around. Here are some examples:

Sometimes it is handy to have a separate virtualenv available for doing batch operations (delete, update, etc.)

You can use the following script to delete all Plone Documents from Solr

>>> from mysolr import Solr
>>> solr = Solr(base_url='http://localhost:8983/solr')
>>> solr.delete_by_query('portal_type:Document')

Advanced Solr Query Syntax#

Simple Query:


A clause can be mandatory (finds only articles containing the word Boston):


A clause can be probibited (finds all articles except those containing the word Vienna):



"Title:Foo AND Description:Bar"

"AND", "OR", "+", "-", "||", "NOT"

Be careful with combining operators such as:

New AND York OR Buenos AND Aires

which will probably lead to no results. You will need to use sub-queries.


(New AND York) OR (Buenos AND Aires)

Range Queries:

"[* TO NOW]"

Boost Terms:


Fuzzy Search:


Proximity Search:

"apache solr"~

with treshold:

"apache solr"~7

Wildcard queries:

To find all cities starting with New you can do:


Or a single character wildcard:


which will find Müller, Miller, etc.

Date math#

Solr provides some useful date units which are available for date queries. The units you can choose of are:

YEAR, MONTH, DAY, DATE (synonymous with DAY), HOUR, MINUTE, SECOND, MILLISECOND, MILLI (synonymous with MILLISECOND) and NOW. All of these units can be pluralized with an S as in DAYS.

effective:[* TO NOW-3MONTHS]

NOW has a millisecond precision. To round down use the / operator (it never rounds up):

effective:[* TO NOW/DAY-2YEAR]

Existing (And Non-existing) Queries#

Assume we want to find all documents which have a value in a certain field (whatever that value is, it doesn't matter).

Find all documents with a description:

Description:[* TO *]

The oposite (finding all documents with no description) is also possible:

-Description:[* TO *]


Faceting is one of the killer features of Solr. It allows the grouping and filtering of results for better findability. To enable faceting you need to turn faceting on in the query and specify the fields you want to facet upon.

For a simple facet query in Solr you activate the feature ("facet=true") and specify the facet fields(s) ("facet.field=portal_type"):


Besides the matching documents this will give you an additional grouping of documents:


There are more complex scenarios possible. For a complete list of options see the respective Solr documentation.

With collective.solr you don't have to worry about the faceting details too much. There is a convenient method to configure the faceting fields in the control panel of collective.solr. All the other magic is handled by the product. We will see an example later.

Search GUIs#

  • collective.solr out of the box: collective.solr comes with its own search view. Since version 6.0 it has been based on React and looks similar to the Plone search view with native facet support of Solr.

  • eea.facetednavigation: This add-on allows faceting out of the box even without Solr. It is a product for integrators to setup search and filter GUIs TTW (Through-The-Web). It can be used for several use cases: Search pages, collection replacements, etc.

  • custom: Another way is to create a custom search page. This is easy to do and we will see later on in this training how.


Do some queries in Solr directly.