1.17.2 Faceting

The search hits are automatically faceted. The configuration is as follows:

<search>
    <facets>
        <field type="range" style="slider" minValue="MIN" maxValue="MAX">YEAR</field>
        <field type="geo" predicate="IsWithin" displayResultsOnMap="true">WKT_COORDS</field>
        <field type="hierarchical" initialElementNumber="4">DC</field>
        <field initialElementNumber="3">DOCSTRCT_TOP</field>
        <field initialElementNumber="3">DOCSTRCT_SUB</field>
        <field initialElementNumber="3" sortOrder="alphabetical_asc" displayValueFilter="false">MD_CREATOR </field>
        <field initialElementNumber="3" priorityValues="Berlin;Göttingen">MD_PLACEPUBLISH </field>
        <field labelField="MD_LABEL">MD_LOCATION</field>
        <field translateLabels="false">MD_OTHERVALUE</field>
        <field sortOrder="alphabetical" groupToLength="1" alwaysApplyToUnfilteredHits="true" skipInWidget="true">MD_TITLE</field>
        <field multiValueOperator="OR">MD_LANGUAGE</field>
    </facets>
</search>

Any number of additional index fields for faceting can be defined via <field> elements. Please note that fields with the prefix FACET_ should exist in the index for this purpose, as these are processed more efficiently due to your configuration. Fields with the prefix FACET_ are automatically generated during indexing for all MD_* fields and for DC, DOCSTRCT, CENTURY and YEAR. Configured should still be the regular field names - the special faceting fields are used internally automatically.

The attribute labelField can contain an index field for label values that differs from the faceting field. For example, grouped metadata containing different names of a city (e.g. "Instanbul" and "Constantinople") can be facetted using a common standard value (e.g. a URI). A value composed of the different names is displayed to the user, and the faceting is done using the standard value.

The attribute translateLabels controls whether listed labels of the facets are to be translated by the messages files. This functionality is active by default and can optionally be switched off.

The displayValueFilter attribute controls whether the search field for filtering the listed faceting values should be shown or hidden. The default is true.

The fields DOCSTRCT_TOP (document type) and DOCSTRCT_SUB (structure element) are generated automatically.

Fields that are searched hierarchically (for example DC) should be configured as <field type="hierarchical">. The attribute initialElementNumber="" defines the number of faceting values initially displayed after a search. All others are displayed by expanding the respective faceting element.). The attribute sortOrder="" can be used to set the initial sorting within the faceting. Possible values are alphabetical_asc, alphabetical_desc, numerical_asc and numerical_desc. If no sortOrder is set, the hits are automatically sorted by occurrence in descending order. The order in the configuration file reflects the order in the interface.

In the attribute priorityValues, (semicolon-separated) values can be specified which should always be sorted on top if these values occur, independent of the other sorting of the faceting values.

With the attribute groupToLength="1" only the first letter is displayed. Larger values are also possible here. With alwaysApplyToUnfilteredHits="true" it is specified that the facets always refer to the entire dataset and not the current filtering. With skipInWidget="true" the display of the faceting option can be hidden in the standard search in the sidebar.

By default, multiple facets are linked with AND. With the attribute and the setting multiValueOperator="OR" this can be adjusted to an OR.

Fields like YEAR can be defined as <field type="range"> and are then displayed in the form of a slider. The optional style="" attribute with the values slider and graph can be used to display the widget as a classic slider (default) or the search hits as a graph. It is also possible to limit the smallest and largest value in the slider with the attributes minValue="" and maxValue="". Either numbers or the values MIN for the smallest or MAX for the largest value in the Solr index are permitted.

If a <field type="geo"> is configured, it must have the value WKT_COORDS, the field through which a geospatial search can be performed in SOLR. Then a map widget will be displayed for each search, through which the search results can be faceted by geographic areas. If there are search results with geographical coordinates, they are displayed in a map above the search results list, too. The attribute displayResultsOnMap can be used to control whether markers are displayed in the map widget for all search hits with geo-coordinates. The default is true.

The <field type="geo"> element can also have a predicate attribute attached to it that describes how to search for matches within a range. There are three possible values:

  1. IsWithin: Finds only hits whose all objects contained in WKT_COORDS - points or polygons - are completely within the search range. This is the default value.

  2. Intersects: Finds all matches of which at least one object contained in WKT_COORDS somehow intersects the search range.

  3. Contains: Finds all hits that contain at least one polygon in WKT_COORDS that completely contains the search range.

Last updated