Search Query

Solr Search in Backoffice has its own Query mechanism.

Search Condition

The class reponsible for Solr Search implementation in Backoffice is the com.hybris.backoffice.solrsearch.dataaccess.facades.DefaultSolrFieldSearchFacadeStrategy class.

A search request is passed in the SearchQueryData, which consists of the searched type and search conditions. Each condition contains information on a searched attribute, comparison operator and chosen value.

  • Simple Search (in reference editor search) takes all fields from the simple-search configuration and a given value in the input box is compared against the configured fields with the contains operator.
  • Search also can be fired with some preconfigured conditions. In this case, you can provide a more complex condition - nested conditions - through API.

Filter Query

Filter Query (fq) parameter restricts the super set of documents that can be returned. It speeds up the search process significantly. In the parsing process of SearchQueryData, the fq applicable conditions are extracted from a query. However, extraction happens only under condition when AND is used as a global operator and a given condition has the same attribute index as the corresponding property type and operator specific operator. It can be configured by modifying the following Spring beans in the backofficesolrsearch/backofficesolrsearch-backoffice-spring.xml:

<alias name="defaultBackofficeFqApplicablePropertiesTypes" alias="backofficeFqApplicablePropertiesTypes"/>
<util:set id="defaultBackofficeFqApplicablePropertiesTypes">
    <util:constant static-field="de.hybris.platform.solrfacetsearch.enums.SolrPropertiesTypes.LONG"/>
    <util:constant static-field="de.hybris.platform.solrfacetsearch.enums.SolrPropertiesTypes.STRING"/>
</util:set>
 
<alias name="defaultBackofficeFqApplicableOperators" alias="backofficeFqApplicableOperators"/>
<util:set id="defaultBackofficeFqApplicableOperators">
    <util:constant static-field="com.hybris.cockpitng.search.data.ValueComparisonOperator.EQUALS"/>
</util:set>

A good example of a condition that can be used in the Filter Query is the CatalogVersion. Since it is a reference, it is indexed as long field (PK of a reference). Also, all enums indexed as string can narrow documents' set, on which the search query is to be performed.

Search Query

Search Query is built from the REST conditions, which are not taken into the filter query, e.g.:

  • For clarity purposes, the simplified version of the search query for the searched term verto may be defined as:

    (name_text_en:verto)
  • The actual search query for the above term looks as follows:

    _query_:"\{\!multiMaxScore\ tie=0.0\}\(\(code_text_en\:verto\^10.0\)\ OR\ \(_backofficeLabel_text_en\:verto\^10.0\)\ OR\ \(name_text_en\:verto\^10.0\)\ OR\ \(pk_string\:verto\^10.0\)\)\ OR\ \(\(code_text_en\:verto\*\)\ OR\ \(_backofficeLabel_text_en\:verto\*\)\ OR\ \(name_text_en\:verto\*\)\)\ OR\ \(\(code_text_en\:\"verto\"\^50.0\)\ OR\ \(_backofficeLabel_text_en\:\"verto\"\^50.0\)\ OR\ \(name_text_en\:\"verto\"\^50.0\)\ OR\ \(pk_string\:\"verto\"\^100.0\)\)"

The multiword input in the text indexed fields is a special case. The following example is for the English name of a Product, where the user input was pny verto:

  • For clarity purposes, the simplified version of the search query for this example can be defined as:

    (name_text_en:pny) OR (name_text_en:verto)
  • The actual search query for the above looks as follows:

    _query_:"\{\!multiMaxScore\ tie=0.0\}\(\(code_text_en\:pn\^10.0\)\ OR\ \(_backofficeLabel_text_en\:pn\^10.0\)\ OR\ \(name_text_en\:pn\^10.0\)\ OR\ \(pk_string\:pn\^10.0\)\)\ OR\ \(\(code_text_en\:verto\^10.0\)\ OR\ \(_backofficeLabel_text_en\:verto\^10.0\)\ OR\ \(name_text_en\:verto\^10.0\)\ OR\ \(pk_string\:verto\^10.0\)\)\ OR\ \(\(code_text_en\:pn\*\)\ OR\ \(_backofficeLabel_text_en\:pn\*\)\ OR\ \(name_text_en\:pn\*\)\)\ OR\ \(\(code_text_en\:verto\*\)\ OR\ \(_backofficeLabel_text_en\:verto\*\)\ OR\ \(name_text_en\:verto\*\)\)\ OR\ \(\(code_text_en\:\"pn\\\ verto\"\^50.0\)\ OR\ \(_backofficeLabel_text_en\:\"pn\\\ verto\"\^50.0\)\ OR\ \(name_text_en\:\"pn\\\ verto\"\^50.0\)\ OR\ \(pk_string\:\"pn\\\ verto\"\^100.0\)\)"

As it can be seen, it's split into tokens and combined in one query.

Customization Through Decorators

You can change the list of conditions before it is used in search through the backofficesolrsearch/backofficesolrsearch-backoffice-spring.xml by adding your own decorator into the below configuration. This list is empty by default.

<alias name="defaultBackofficeConditionsDecorators" alias="backofficeConditionsDecorators"/> 
<util:list id="defaultBackofficeConditionsDecorators" 
	value-type="com.hybris.backoffice.solrsearch.decorators.SearchConditionDecorator"> 
</util:list>