Simple Search and Filters Widget
The Simple Search and Filters widget provides search mechanism enriched by autosuggestion and autocorrection functionality.
Widget Definition
| Name | Simple Search and Filters |
| ID | com.hybris.cockpitng.fulltextsearch |
| Category | Search |
| Description | Provides search mechanism enriched by autosuggestion and autocorrection functionality. |
| Applied In | Not applicable |
| Based On | Not applicable |
| Author | SAP |
| Inputs |
Details of input sockets:
|
| Outputs | Details of output sockets:
|
| Generated Events | Not applicable |
Configuration
Configuration of this widget is defined by the fulltext-search.xsd file.
The following elements can be used in your configuration file:
-
fulltext-search: Root element.
-
field-list: Contains the fields that are available for search.
-
field (0+): Defines a search field.
-
@position (int): Defines field's index within the field list.
-
@name (java.lang.String, required): Qualifier of the field to display as a search condition.
- @label (java.lang.String): label to be used as a UI representation of this field.
- @displayName (java.lang.String): displayed name of the current field (used when no label is provided).
-
@selected (java.lang.Boolean): If true, the field is preselected and displayed as the search attribute when opening field query popup. Default value: false.
-
@editor (java.lang.String): Editor to be used to display the search condition value. If not specified, the default editor for the field's type is used.
-
@merge-mode (java.lang.String): Defines configuration merging mode. Possible values: merge, replace, remove. Default value: merge.
-
editor-parameter (0+): Specifies parameters for current editor. The available parameters are defined in the documentation of each particular editor.
-
name (java.lang.String): parameter name
-
value (java.lang.String): parameter value
-
-
-
-
preferred-search-strategy: preferred search strategy to be used in subsequent calls. Possible values: flexible, solr. Default value: flexible.
- operator: preferred operator. Possible values: and, or. Default value: and.
-
Based on the schema above, you can have, for example, the following configuration:
<context type="Product" component="fulltext-search"> <fts:fulltext-search xmlns:fts="http://www.hybris.com/cockpitng/config/fulltextsearch"> <fts:field-list> <fts:field name="code" selected="true" /> <fts:field name="description" /> <fts:field name="catalogVersion" /> </fts:field-list> <fts:operator>OR</fts:operator> </fts:fulltext-search> </context>
Widget Preview
Figure: Click the magnifying glass icon to trigger the input field where you can type your search query, and click the filter icon to check and add your filters.
Figure: Simple Search and Filters widget with an added filter.
Settings
| Setting | Type | Description |
|---|---|---|
| actionSlotComponentName | java.lang.String | Defines the name of the UI configuration component code to be used when loading the action set for the collection browser. Default value: fullTextSearchActions. |
| minAutosuggestionsQueryLength | java.lang.Integer | Defines the minimum query length, after which the request is sent for autosuggestions. It gives results if the search for the current type is full text search. Default value: 3. |
| fulltextSearchConfigCtxCode | java.lang.String | Defines the UI configuration context code to use in the Simple Search and Filters widget. Default value: fulltext-search. |
| simpleSearchConfigCtxCode | java.lang.String | Defines the UI configuration context component code for simple mode. Default value: simple-search. |
| fieldQueryEnabled | java.lang.Boolean | Defines if filtering by fields is enabled. Default value: true. |
| preferredSearchStrategy | java.lang.String | Preferred search strategy to be used in subsequent calls. Possible values: flexible, solr. Default value: flexible. |
Widget Slots
| slotID | Multiplicity | Type | Slots Composition |
|---|---|---|---|
| cockpitWidgetChildrenInvisible | multi | Not applicable | A general-purpose slot available for widgets. Any widget placed on this slot is not displayed in the application view but can be accessed through its socket API. |
Simple Search and Filters Fallback Strategy
Simple Search and Filters widget has a default DefaultFulltextSearchConfigurationFallbackStrategy which retrieves all mandatory attributes for a given context.
When backofficesolrsearch extension is enabled, the DefaultFulltextSearchConfigurationFallbackStrategy strategy is overridden with the SolrFullTextSearchConfigurationFallbackStrategy strategy, which creates filters based on the Indexed Properties defined in BackofficeProduct indexed type.
Filter label is resolved in the following manner:
-
If FieldType configuration has defined a key to a label in label attribute, then it returns a localized label in current locale. For details, see the Localizing UI of the Backoffice Application document.
-
If FieldType configuration has defined a displayName attribute, its value is returned.
-
If neither label nor displayName are defined, then filter label representation is returned. For details, see the base Configuration section.
Preferred Search Strategy
There might be multiple possible search strategies available in the system, like flexible or Solr search. Simple Search and Filters widget allows changing preferred strategy on runtime.
A new strategy setting a context configuration can be read from the widget (context configuration overrides the setting). If a new strategy is set, it is stored in the widget model under the com.hybris.backoffice.widgets.fulltextsearch.FullTextSearchController#MODEL_PREFERRED_STRATEGY key. It might be accessed by any element related to the widget. By default, the com.hybris.backoffice.widgets.fulltextsearch.renderer.impl.DefaultFieldQueryFieldRenderer renderer contains a mapping from received strategy to an actual bean implementing the com.hybris.backoffice.widgets.fulltextsearch.FullTextSearchStrategy interface. If the map does not contain requested strategy, then default is used.
If new strategy is to be defined, then new com.hybris.backoffice.widgets.fulltextsearch.FullTextSearchStrategy implementation should be created and registered as a Spring bean. Then, if only the com.hybris.backoffice.widgets.fulltextsearch.renderer.impl.DefaultFieldQueryFieldRenderer renderer is used, it should be registered as a new key in searchStrategies map of fieldQueryFieldRenderer bean. To do this, the extender bean should be defined:
<bean id="someFullTextSearchStrategiesExtender" class="com.hybris.cockpitng.core.util.impl.MapPropertyExtender" lazy-init="false" init-method="extend" destroy-method="clean"> <property name="parentBean" ref="fieldQueryFieldRenderer"/> <property name="propertyName" value="searchStrategies"/> <property name="additionalProperties"> <map key-type="java.lang.String" value-type="com.hybris.backoffice.widgets.fulltextsearch.FullTextSearchStrategy"> <entry key="strategyIdentifier" value-ref="newStrategyBean"/> </map> </property> </bean>