The Solr search tool can be accessed via the ribbon in the Home tab, Tools category, or via the criteria panel of most classic search tools, where it is possible to switch between advanced searches and Solr searches.

This type of search is intended for advanced users only. It allows you to build very advanced searches and has its own syntax. Criteria, comparison operators, logical operators, columns and facets are free. The main restriction is the selection of at least one content type.

This document covers the following points:

  1. Interface presentation
  2. Criteria panel
    1. Content type(s) and role(s)
    2. Request
      1. Syntax
        1. Comparisons
        2. Logic operators
        3. Rough search
        4. Weight in queries
      2. Field suffix
      3. Joined queries
    3. Columns and facets
      1. Columns
      2. Veneers
  3. Useful links

Interface presentation

The tool is composed of several zones: points 1 to 5 correspond to the creation of the search query, and zone 6 corresponds to the search results.

  1. Content type(s) and role(s)
    This is the main context. This field is mandatory, and is used to indicate which types of content will be searched.
  2. Query
    This is where you define the query clauses. In the rest of this document, we'll look in more detail at how to build a query and the different possibilities available.
  3. Columns
    This field lets you select the columns that will appear in the search results.
  4. Facets
    Facets are designed to create dynamic, countable filters on field values.
  5. Search buttons
    These buttons can be used to launch or cancel a search. They are the same as for a simple or advanced search.
  6. Results display
    Same as other search tools, with the option of sorting, grouping, faceting, pagination of results, etc.

Criteria panel

Auto-completion (Ctrl + Space) is available at all levels of the Solr search tool. We strongly advise you to use and abuse it.

Content type(s) and role(s)

Selecting the content type (or role) allows you to draw a main context that will be used to define which fields will be available for auto-completion in the other areas of the search criteria panel.

The operator used between the different types or roles selected is the "OR" choice operator. As a result, if several content types or roles are selected, auto-completion will be limited to the highest common content type between all selected values. For example, if in the content types, the user selects the "Period" and "Field" training offer reference tables, only the fields from the content type common to these two types will be usable (in this case, the fields from the "Reference table ODF" type). In the absence of a common content type, only standard fields are available.

The search for roles and content types is not strict, i.e. it takes inheritance into account. For example, in the training offer, all content types inherit the "Content ODF" content type. If this type is selected, all content with a content type inheriting from "Content ODF" will be displayed: ELP, ELP list, training, etc.

Request

To build a query, you need to know the overall syntax of a query, including comparison operators and logical operators. But that's not all: you also need to understand how the suffixes added to field names work. Auto-completion will be a great help in constructing a query.

You can then take this a step further by using joined queries to perform deep searches.

Syntax

By default, the requester is filled with the following value:

*:*      

This allows all results to be returned unfiltered.

The separator between a field and a value is ":".

title:histoire      

title is the name of the field and story is the searched value.

Comparisons

An exact expression must be enclosed in quotation marks.

title:"Licence Histoire"      

It is possible to make intervals of closed or open values. The separator between the two values is the keyword "TO".
Square brackets ("[" and "]") are used to include boundary values.
Braces ("{" and "}") are used to exclude boundary values.
One end of the interval can be open and the other closed.

Filters on the "annee" field whose value is between 2008 and 2018 but cannot be equal to 2008 or 2018 :

annee:{2008 TO 2018}     

Filters by "annee" field if value is less than or equal to 2018 :

annee:[* TO 2018]     

Filter on "annee" field whose value is strictly greater than 2008 :

annee:{2008 TO *]     

Intervals can also be used to test whether a field has been filled in:

annee:[* TO *]     
Logic operators

Classically, there are 3 logical operators:

  • AND" or "+" concatenation
  • OR" or "(empty)" choice
  • NOT" or "-" negation

Negation operators deduce a part of a set of results. The preceding clause must therefore express the results to which we want to apply the negation clause. For this reason, we prefer to write this clause with "-".

It's important to separate groups with parentheses ("(" and ")"), especially when operators change. It can be clever to isolate each clause within parentheses too.

As we can see from the list above, there are several ways of writing a group of clauses: we can use full notation (AND, OR, NOT) or abbreviated notation (+, (empty), -). Both notations can be mixed.

These two queries are equivalent (all content with the title "history" and the description "art"):

(title:histoire) AND (description:art)     
+(title:histoire) +(description:art)     

Like the three that follow and mix up the notations (all content with "history" as the title and a level but not "archaeology" as the description) :

((title:histoire) AND (level:[* TO *])) -(description:archéologie)     
((title:histoire) AND (level:[* TO *])) NOT(description:archéologie)     
(+(title:histoire) +(level:[* TO *])) NOT(description:archéologie)     

It's important to note that the negative operator is always preceded by a context. If we want to obtain all content whose title is not "story", we'll have to write the following:

*:* -(title:histoire)     

Logical operators can also be used in :

title:(+histoire -art)     
title:(histoire AND art)     
title:((histoire OR géographie) AND master)     
Rough search

Searches are based on exact terms, but it is possible to add wildcards to them. There are various types of wildcard, and here are the main ones:

  • "?" replaces an unknown character

  • "*" replaces zero to several unknown characters
  • "~[n]" where [n] is replaced by a number and represents the number of characters or the distance between two terms.

The following expression also refers to all content with the title "road", "roll", "red", etc. :

title:rou?e    

This returns content with titles identical to the words mentioned above, but also longer or shorter words such as "roue", "roulade", "rougie", etc. :

title:rou*e    

This new expression refers to content whose title is close to a character, such as "bouge", "route", "ronge" and so on. :

title:rouge~1    

It's also possible to define the maximum distance between two terms. In this expression, Solr returns content whose title contains the words "license" and "history" with a maximum distance of 10 characters between the two terms.

title:"licence histoire"~10    
Weight in queries

To help sort results by relevance, the syntax of the Solr expressions offers the possibility of adding weights, called "boosts", and represented by the "^" character.

(title:histoire)^1.5 OR (description:histoire)    

Here, results with "story" in the title will be more relevant than those with "story" in the description.

Field suffix

A field present in Ametys can be indexed in different ways in Solr. It is always suffixed, except for standard fields. Below is a list of the different suffixes used when indexing data, and which should therefore be used when building your queries.

Each Solr field can be multivalued.

The basic field name is represented by [fieldName].

Syntax

Comment

Example

String

[fieldName]_s

Exact comparison (case and accents taken into account)

title_s:Geography

[fieldName]_s_lower

Search on lowercase field value

title_lower_s:geography

[fieldName]_txt_en

Full-text search (term by term, case and accents ignored)

title_txt_en:GEOgraphy

Single fields

[fieldName]_l

Integer (long)

duration_l:20

[fieldName]_d

Decimal number (double)

etcs_d:15

[fieldName]_b

Boolean (true/false)

openToExchangeStudents_b:true

[fieldName]_dt

Date (datetime, values in ISO format)

startDate_dt:2018-12-20T00:00:00.000Z

Complex fields

[fieldName]_s

Content (identifier comparison)degree_s:"content://a52db23d-fbf2-42a6-98b4-384d3914aeb0"

[fieldName]_txt_stemmed_en

Rich textpresentation_txt_stemmed_en:geography

[composite]/[fieldNameWithSuffix]

Compound fieldpiloting/piloting_status_s:CFVU_VALIDATED
[fieldName]_geoGeographical coordinates (distance in kilometers){!geofield sfield=geoCode_geo pt=45.62,-0.12 d=10}
Standard fields
contentLanguageContent languagecontentLanguage:fr
workflowStepWorkflow status (long)workflowStep:3
creatorContent creator (login#population)creator:bmaurel#cms-users
contributorLast contributor (login#population)contributor:bmaurel#cms-users
creationDateCreation datecreationDate:2018-12-20T00:00:00.000Z
lastModifiedDate of last modificationlastModified:2018-12-20T00:00:00.000Z
lastValidationLast validation datelastValidation:2018-12-20T00:00:00.000Z
full_enSearch all text, rich text and content documents (no auto-completion)full_en:psychology

Full-text search
In full-text, each word in the field is searched independently, unlike other types of search where the entire value is searched. So you can search on one or more words in the field.

Geographic coordinates
The syntax presented above for geographic coordinates is not available in AutoComplete, but can still be used in the Solr querier.
Parameters:
> sfield is the field on which the search is performed
> pt is used to define a starting geographic coordinate
> d is the search radius in kilometers around this point.

Standard fields (also known as system fields)
Not all system fields are shown here, as some are only available with certain plugins functions, so it is not relevant to list them exhaustively.
They are visible via auto-completion and are not suffixed. Their type is noted in brackets in auto-completion, so simply refer to them and treat them like any other field, but without the suffix.

Joined queries

To make expressions that take into account values contained in repeaters or linked content, there are joined queries.

They are accessible via auto-completion directly by typing the name of the repeater field, but not for linked content. However, the "join" keyword automatically constructs the syntax of a joined query:

{!ametys join= q=""}    

It is composed of two parameters:

  • "join" indicates the path to the repeater or content field
  • "q" for the subquery, this parameter is optional
{!ametys join=internshipDescription q="period_l:4"}    

This expression is used to search for all content for which the training period takes place in April.

Another way of writing restriction clauses is to use square brackets ("[" and "]") to enclose the :

{!ametys join=internshipDescription[period_l:4]}    

Finally, to make multi-level joins, simply use "->" to explore the fields.

To find the managers of a course whose name begins with "a" :

{!ametys join=personInCharge->persons q="givenName_txt_fr:a*"}    

It is possible to mix clauses in square brackets and clauses in the q parameter, for example to search for all persons whose role is "responsible" and whose name begins with "a" :

{!ametys join=personInCharge[role_s:responsable]->persons q="givenName_txt_fr:a*"}    

Auto-completion remains available at all join levels, taking into account the current context.

Columns and facets

The values displayed in the columns and facets of search results are extracted directly from the content, not from the indexing server. For this reason, field names are not suffixed as in Solr queries.

Selected fields are separated by commas.

To perform an in-depth search (exploration of a complex field (composite, repeater, content)), it is necessary to use the separator "." between each level.

The default label displayed for each column or facet element is the field label in Ametys.

Columns

This field represents the list of columns displayed in search results.

A column can be renamed to give it a more explicit or complete name, using the "AS" keyword.

If this field is left empty, the columns "Title", "Creation date", "Last modified", "Last contributor", "Creator", "Status", "Language", "Content type(s)" and "Strict role(s)" are displayed.

 To display the "Title", "Code" (the nature of the ELP) and "Hourly volume" columns:

title, courseType.code, nbHours

However, to be more precise on the title of the second column, it is possible to do this, so we will have the columns "Title", "Nature" and "Hourly volume" :

title, courseType.code AS Nature, nbHours

The "*" symbol has also been integrated to display all content fields:

*

It is possible to go further by displaying only the fields of a linked content or compound field (multiple or not), for example by displaying the title, component details and illustration details of a course:

title, orgUnit.*, illustration.*

Veneers

Facets enable fast, dynamic filtering of field values, making it easy to filter content according to standard field values (content type, language, workflow status, orphan, etc.) or model values (nature, catalog, etc.). They are pre-calculated at query time.

In this element, only fields with a limited number of values can be selected. These include listed fields, content fields, user fields and Boolean fields. For example, it is impossible to have a facet on title. If data with unrestricted values is selected, it will be ignored.

In the following example, based on the "ELP" training offer content type, only the "Catalog" and "Contributor" facets are calculated:

catalog, courseType.code, contributor, title      

But it is possible to display the "Nature" facet because it is itself a content or limited sub-data of the latter:

catalog, courseType, contributor, courseType.contributor      

If this field is left empty, no facet is calculated.

Useful links

Documentation Solr 7.5

Syntax tutorial Solr

 

Back to top