cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

How to configure wild cards in solr?

Former Member
0 Kudos
935

Hello,

In the store front search box I can enter tes*

How do I configure the wild cards in solr for search criteria so that it will return the results properly.

Thanks in advance.

Accepted Solutions (0)

Answers (2)

Answers (2)

0 Kudos

Hey

Firstly, I kindly suggest you get familiar with Solr Search Features on this page: https://wiki.hybris.com/display/hybrisALF/Solr+Search+Features

There are mainly 4 settings that you can configure in the Solr query:

  1. Field - which corresponds to a indexed type*

  2. Boost – which is the amount of relevancy for the field*

  3. Wildcard - When you want to use variations of words and phrases

  4. Term Proximity – which is the moving terms position of the n spaces combined

(*) On the OOTB configuration.

The fields and the boost can be easily configured on the SearchTextPopulator. The SearchTextPopulator is defined in the commerceservice-spring-solrfacetsearch.xml file in commerceservices extension, under resources folder. Each property name corresponds to a field and their boost.

In order to configure the Wildcard or the Term Proximity or other settings you have to follow the next steps: 1. Create your own customFreeTextQueryBuilder extending from DefaultFreeTextQueryBuilder. 2. Override the addFreeTextQuery method with your logic. Take a look at de.hybris.platform.commerceservices.search.solrfacetsearch.querybuilder.impl.AbstractFreeTextQueryBuilder file as a guide. 3. Add the commerceservices as a required extension in your extension’s extensioninfo.xml file. 4. Define the new bean in your extension in your extension’s yourextension-spring.xm*l file so that it overrides the initially used DefaultFreeTextQueryBuilder. Here’s the example:

 <alias name=“customCommerceSearchTextPopulator" alias="commerceSearchTextPopulator" />
 <bean id="customCommerceSearchTextPopulator" class="de.hybris.platform.commerceservices.search.solrfacetsearch.populators.SearchTextPopulator">
     <property name="freeTextQueryBuilders">
         <list>
             <bean class="org.training.querybuilder.CustomFreeTextQueryBuilder">
                 <property name="propertyName" value="ean" />
                 <property name="boost" value="100" />
             </bean>
             <bean class="org.training.querybuilder.CustomFreeTextQueryBuilder">
                 <property name="propertyName" value="code" />
                 <property name="boost" value="90" />
             </bean>
     ...

Alternatively you can also make some changes using back office. Go to Backoffice -> System -> Facet search -> Facet Search Config.

Hope that helps,

Former Member
0 Kudos

Thanks for your quick reply Wojciech.

bastian_kromer
Explorer
0 Kudos

Hi,

in the backoffice -> system -> facet search -> indexed types, you should find a list of (indexable) attributes for each type. For example you´ll have a product, with an attribute "name" that should be relevant for solr search. For this attribute you can "Edit Details" which will lead you to a lot of search options, including a minimum input length to trigger the search, fuzzy search options, and wildcard search settings.

Former Member
0 Kudos

Thanks for your quick reply Bastian.