on 04-28-2016 4:37 PM
Hi, I completely new to solr search. I have to implement a functionality through which the auto complete displays a combination of brand and product keyword as a single suggestion. For example- If brand is hyperice and its products associated are vyper,ice compression ,etc. Then the dropdown should be displayed hyperice-vyper,hyperice-ice compression, on typing hyper in the search box.
Based on Version 6.0
The search box is actually a component (SearchBoxComponent) with some flags which can be configured. Flags like,
displayProductImages
displayProducts
displaySuggestions
If you then need to have additional information like brands, then you need to tweak the following part of the code in com.zooplus.storefront.controllers.pages.SearchPageController#getAutocompleteSuggestions
if (component.isDisplaySuggestions())
{ resultData.setSuggestions(subList(productSearchFacade.getAutocompleteSuggestions(term), component.getMaxSuggestions()));
}
if (component.isDisplayProducts())
{ resultData.setProducts(subList(productSearchFacade.textSearch(term).getResults(), component.getMaxProducts()));
}
Into the resultData you can add Brand facets from the result of productSearchFacade.textSearch(term). But this will give you only brands of the products in the search result.
If you want brands for a search term instead, which may or may not have products matching the term, you can do a separate search for brands and add it to the resultData.
Based on Version 5.2
I have a working code for 5.2 where we did a similar thing as is described for version 6.0
Here is an example
final SearchBoxComponentModel component = (SearchBoxComponentModel) cmsComponentService.getSimpleCMSComponent(componentUid);
if (component.isDisplaySuggestions())
{
resultData.setCategorySuggestions(subList(getCategorySuggestions(term), (component.getMaxProducts().intValue() + 1)));
resultData.setKeywordSuggestions(getKeywordSuggestions(term));
resultData.setSuggestions(subList(productSearchFacade.getAutocompleteSuggestions(term), component.getMaxSuggestions()));
resultData.setProducts(subList(productSearchFacade.textSearch(term).getResults(), (component.getMaxProducts().intValue() + 1)));
}
Therefore, I believe there was a SearchBoxComponent in 5.0 as well.. please check again
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
The search box component (https://wiki.hybris.com/display/accdoc/Search+Box+Component) was added in 5.1. You can try to backport it yourself, otherwise you will need to upgrade or build your own implementation. Be aware that as of 31.05.2016 anything <=5.1 is no longer supported by Hybris.
Abhishek,
There are two section(getAutocomplete() and getProducts in searchPagecontroller) one keyword suggestion(getAutocomplete()) means you can select from HMC>facet search config>Index type> List of index properties here there is option auto-complete just click on the check box for the field you want to consider auto suggestion. For product search(getProducts) you can configure query fields in the *your*core-spring.xml as follow
<alias name="defaultCommerceSearchTextPopulator" alias="commerceSearchTextPopulator" />
<bean id="defaultCommerceSearchTextPopulator"
class="de.hybris.platform.commerceservices.search.solrfacetsearch.populators.SearchTextPopulator">
<property name="freeTextQueryBuilders">
<list>
<!-- <bean class="de.hybris.platform.commerceservices.search.solrfacetsearch.querybuilder.impl.DefaultFreeTextQueryBuilder">
<property name="propertyName" value="brand" /> <property name="boost" value="100"
/> </bean> -->
<bean
class="de.hybris.platform.commerceservices.search.solrfacetsearch.querybuilder.impl.DefaultFreeTextQueryBuilder">
<property name="propertyName" value="name" />
<property name="boost" value="100" />
</bean>
</list>
</property>
</bean>
Here add the field on which you want search think it helps you.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
HI, Currently the dropdown displays only 5 keywords which opens up the search list page and a few keyword redirects have been applied which redirects to the brand page. What I want in the dropdown is more than 5 in the list and the order to come as following DropDown
Brands: Posture Medic®\ Posture Pro Posture Pulley Top 5 Products: Posture Pump® Cervical Disc Hydrator Model 1100 Posture Pump Elliptical Back Rocker Model 2000 etc etc etc Did You mean? Something Something 2 Something 3
Can you help?
Find the controller probably it will be Searchpagecontroller, here can find the configuer max count. If I correctly understand you, so just tick checkbox for autocomplete for Brands index properties. And for product suggestion jaust put brands and product title in the query. So just customize it in above xml.
HI Abhishek, I didnt find any configure max count option. Is it a property? Also if I add the property in spring.xml with a higher boost value so will it return the brands as a part of the autocomplete dropdown so that clicking on it will redirect me to the brand page? Brand is an itemtype inside product.
Take a look at SearchPageController.getAutocompleteSuggestions. You can see that it is calling productSearchFacade.getAutocompleteSuggestions and using the properties defined on the SearchBoxComponentModel. This page has a lot of detail on how the autocomplete functionality works.
If it's really only the result of the search coming back that isn't what you want then you should look at analyzing your solr query scoring (set log4j.logger.de.hybris.platform.solrfacetsearch.search.impl.DefaultFacetSearchService=DEBUG) to see why particular results are coming back in the order they are. You can then adjust this via:
Adjusting your solr scoring parameters and ensure fuzzy search is set up correctly for your "brand" attribute so it matches hyperice*
Adjusting your solr schema (not specific to hybris)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
What I am referring to here is not boosting a few products up. Whatever the search I did For example if I typed in ab in the search box then the suggestions that should return is, first brands containing ab,then a few products containing the name ab and then at last did you mean with a few suggesstions in the dropdown. Currently it just returns a set of keywords.
This is showing different products and not a combination of brand and product which is out of the box. I need to modify out of the box autocomplete.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
5 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.