sf_resultsmodel
This Bundle contains the API for starting a search and for storing and accessing the search results.
This documentation refers to the programmatic usage of the components in this bundle is aimed at software developers. It is not relevant for the sole configuration of apps.
Searching
Setting the search term and starting a search
To set the search term programmatically and trigger a search, set the property searchTerm
on the Query
component.
this.query.searchTerm = "wasser";
Defining additional search criteria
To narrow a search you can specify certain values for single fields that each result item must have.
In the following example we search for items whose publisher is "con terra GmbH":
this.query.addCriterion("publisher", "con terra GmbH");
Accessing the search results
You can access the search results through the property results
of the ResultsModel
component.
Requesting results in chunks (paging)
It is inefficient and slow to always load all results of large result sets. Therefore, by default, only 20 results are loaded in one server request. To load the next 20 results (i.e. the next page) call the method fetchResultsWithoutFacetInfo()
of the ResultsFetcher
component. The additional results are then added to the end of the array in the results
property of the ResultsModel
component.
You can configure the page size, that means the number of results per page, in your app.json
file as such:
{
"bundles": {
"sf_resultsmodel": {
"ResultsModel": {
"pageSize": 30
}
}
}
}
Search field configuration
The smart.finder search works on three different fields of its Solr core. This depends on whether a simple, phrase or wildcard search is being performed, because for each search scenario is an own field defined.
If you want to provide your own fields, you can configure on which field the searches should be executed. This can be
done with the properties defaultSearchFieldName
, wildcardSearchFieldName
and phraseSearchFieldName
as follows:
"sf_resultsmodel": {
"Query": {
"defaultSearchFieldName": "full_text",
"phraseSearchFieldName": "full_text_p",
"wildcardSearchFieldName": "full_text_w"
}
}
Requesting a single item by ID
Use the DetailItemFetcher
component's fetch(id)
to request a single item by its ID. The result is written to
the DetailItemModel
component.
Facets configuration
Facets are attributes that can be filtered by their values. In smart.finder the facets are displayed in expansion panels where each facet represents an attribute that can be filtered.
The facets to display are configured on the DocumentStore
component of the sf_store
bundle. Additionally, you can
specify which facets and values to show based on the user's permissions or hide facets completely.
The configuration component InitialFacetsPropertiesConfig
Facet properties and displayed values are configured on the InitialFacetsPropertiesConfig
component with the facets
and the defaultValues
properties.
defaultValues
holds a single object. This object contains the configuration properties that apply to all facets.
Individual settings for facets can be specified using the facets
property.
facets
is an array of objects where each object holds the configuration for a certain facet. Settings made here
override the settings in defaultValues
.
In the following example all facets will be expanded, except for the type facet:
{
"sf_resultsmodel": {
"InitialFacetsPropertiesConfig": {
"defaultValues": {
"panelExpanded": true
},
"facets": [
{
"name": "type",
"panelExpanded": false
}
]
}
}
}
The single configuration objects for the facets must have a name
property to identify the facet to configure.
Additional properties are:
name
: The name of the facet to configure, e.g. "catalogName". This property is always required when configuring a single facet.hide
: Whether the facet should be hidden. Possible values:true
andfalse
.marked
: Whether the facet should be displayed in a highlighted fashion. For example, facets only visible to administrator users are "marked". Possible values:true
andfalse
.panelExpanded
: Whether the panel containing the values for the facet should initially be open or closed. Possible values:true
andfalse
. Please note: The facet for specifying the current geo-extent is part of the bundlesf_geo-extent-filter
and is configured there.requiredPermissions
: An expression to define the users that are permitted to see the facet. See below for details.valueRestrictions
: Restrict the values displayed for a facet to certain user permissions. See below for details.sortAttribute
: The name of the attribute the values within a facet are sorted by. Possible attribute names are "title" and "count". Default value is "title".sortDescending
: Whether to sort the values within a facet in descending order. Possible values:true
andfalse
. Default value isfalse
.
requiredPermissions
The following values are valid:
- A string like
ADMIN
to define a single permission that is required. - You can also specify an array of permission names to express that all those permissions are required to view the
facet. For example
["EDIT_MD", "DELETE_MD"]
says that the permissions "EDIT_MD" and "DELETE_MD" are required. - To define expressions with an OR operator:
{"ADMIN", {$some: ["EDIT_MD", "DELETE_MD"]}}
. This means at least the" ADMIN" permission is required or both the "EDIT_MD" and the "DELETE_MD" permissions are required to view the facet.
At runtime the configuration values are applied to the corresponding properties in the FacetsModel
component. The
objects held by the FacetsModel
are reactive which means you can change their values at runtime and changes are
reflected in the UI immediately.
valueRestrictions
To limit the values displayed for a facet to certain user permissions define the valueRestrictions
property. Here's an
example:
{
"InitialFacetsPropertiesConfig": {
"facets": [
{
"name": "owner_facet",
"valueRestrictions": [
{
"ifHasPermissions": [
"ADMIN"
],
"allowedValues": "*"
},
{
"elseIfHasPermissions": [
"GROUP_ADMIN"
],
"allowedValues": [
"${userGroup}"
]
},
{
"allowedValues": [
"a",
"b"
]
}
]
}
]
}
}
valueRestrictions
is an array of objects where each object contains a condition relating the user's permissions, and a
list of the allowed facet values that the user in possession of these permissions will see in the facets.
The first object in the array will apply when the user has the "ADMIN" permission, i.e. the user is allowed to see all
values ("allowedValues": "*"
).
If the user does not have the "ADMIN" permission but the "GROUP_ADMIN" permission the second object applies which means
the user can only see the value which equals the user's user group. ${userGroup}
is a variable which is replaced with
the name of the user group at runtime. Possible variables are ${userGroup}
and ${userName}
.
The third object applies when the user has neither the "ADMIN" permission, nor the "GROUP_ADMIN" permission. That user can only see the values "a" and "b" of the "owner_facet".
Translating facet values
For translating single values in facets to the current application language, specify
the sf_resultsmodel.facet-value-translations
key in the bundle.js
files in the nls
folder of your app. It must be
an object where each key is the name of a facet. For each facet specify an object with the values to translate on the
left, and the translations on the right-hand side.
Example from the file myapp/nls/de/bundle.js
:
{
"sf_resultsmodel": {
"facet-value-translations": {
"visibility_facet": {
"private": "User",
"protected": "User group",
"public": "Public"
}
}
}
}