cancel
Showing results for 
Search instead for 
Did you mean: 

SAP COMMERCE search query template can use DEFAULT & SUGGESSTIONS keys together?

former_member816846
Discoverer
0 Kudos

I tried to add two query templates DEFAULT and SUGGESTIONS because without DEFAULT using only SUGGESTIONS the search result is not correct (facets are not shown)

how can I configure these two templates together?

or show me the correct way how to configure one of them and see the correct results!!!!!!

$solrIndexedType=marketplaceProductType<br><br># Search query template<br>INSERT_UPDATE SolrSearchQueryTemplate;name[unique=true];indexedType(identifier)[unique=true];ftsQueryBuilder<br>                                     ;SUGGESTIONS;$solrIndexedType;defaultFreeTextQueryBuilder<br>                                     ;default;$solrIndexedType;defaultFreeTextQueryBuilder<br># Non-facet search query properties<br>INSERT_UPDATE SolrSearchQueryProperty   ;indexedProperty(name, solrIndexedType(identifier))[unique=true];searchQueryTemplate(name, indexedType(identifier))[unique=true][default=SUGGESTIONS:$solrIndexedType];facet   ;ftsPhraseQuery[default=false]  ;ftsPhraseQueryBoost;ftsQuery[default=false];ftsQueryBoost  ;ftsFuzzyQuery[default=false];ftsFuzzyQueryFuzziness ;ftsFuzzyQueryBoost ;ftsWildcardQuery[default=false];ftsWildcardQueryType(code)[default=POSTFIX];ftsWildcardQueryBoost  ;ftsWildcardQueryMinTermLength  ;includeInResponse[default=true];<br>                                        ;name:$solrIndexedType                                         ;                                                                                                       ;       ;TRUE                           ;                   ;TRUE                   ;               ;TRUE                        ;1                      ;110                ;TRUE                           ;PREFIX_AND_POSTFIX                         ;                       ;                               ;<br>                                        ;categoryName:$solrIndexedType                                 ;                                                                                                       ;       ;TRUE                           ;                   ;TRUE                   ;               ;TRUE                        ;1                      ;110                ;TRUE                           ;PREFIX_AND_POSTFIX                         ;                       ;                               ;<br>                                        ;brandName:$solrIndexedType                                    ;                                                                                                       ;       ;TRUE                           ;                   ;TRUE                   ;               ;TRUE                        ;1                      ;110                ;TRUE                           ;PREFIX_AND_POSTFIX                         ;                       ;                               ;<br>                                        ;code:$solrIndexedType                                         ;                                                                                                       ;       ;                               ;                   ;                       ;               ;                            ;                       ;                   ;                               ;                                           ;                       ;                               ;<br>                                        ;itemtype:$solrIndexedType                                     ;                                                                                                       ;       ;                               ;                   ;                       ;               ;                            ;                       ;                   ;                               ;                                           ;                       ;                               ;<br>                                        ;description:$solrIndexedType                                  ;                                                                                                       ;       ;                               ;                   ;                       ;               ;                            ;                       ;                   ;                               ;                                           ;                       ;                               ;<br>                                        ;summary:$solrIndexedType                                      ;                                                                                                       ;       ;                               ;                   ;                       ;               ;                            ;                       ;                   ;                               ;                                           ;                       ;                               ;<br><br><br><br>INSERT_UPDATE SolrSearchQueryProperty;indexedProperty(name, solrIndexedType(identifier))[unique=true];searchQueryTemplate(name, indexedType(identifier))[unique=true][default=default:$solrIndexedType];facet   ;ftsPhraseQuery[default=false]  ;ftsPhraseQueryBoost;ftsQuery[default=false];ftsQueryBoost  ;ftsFuzzyQuery[default=false];ftsFuzzyQueryFuzziness   ;ftsFuzzyQueryBoost ;ftsWildcardQuery[default=false];ftsWildcardQueryType(code)[default=POSTFIX];ftsWildcardQueryBoost  ;ftsWildcardQueryMinTermLength  ;includeInResponse[default=true]<br>                                     ;name:$solrIndexedType                                         ;                                                                                                       ;       ;TRUE                           ;                   ;TRUE                   ;               ;TRUE                    ;1                        ;110                ;TRUE                           ;PREFIX_AND_POSTFIX                         ;                       ;                               ;<br>                                     ;categoryName:$solrIndexedType                                 ;                                                                                                       ;       ;TRUE                           ;                   ;TRUE                   ;               ;TRUE                    ;1                        ;110                ;TRUE                           ;PREFIX_AND_POSTFIX                         ;                       ;                               ;<br>                                     ;brandName:$solrIndexedType                                    ;                                                                                                       ;       ;TRUE                           ;                   ;TRUE                   ;               ;TRUE                    ;1                        ;110                ;TRUE                           ;PREFIX_AND_POSTFIX                         ;                       ;                               ;<br>                                     ;code:$solrIndexedType                                         ;                                                                                                       ;       ;                               ;                   ;                       ;               ;                        ;                         ;                   ;                               ;                                           ;                       ;                               ;<br>                                     ;itemtype:$solrIndexedType                                     ;                                                                                                       ;       ;                               ;                   ;                       ;               ;                        ;                         ;                   ;                               ;                                           ;                       ;                               ;<br>                                     ;description:$solrIndexedType                                  ;                                                                                                       ;       ;                               ;                   ;                       ;               ;                        ;                         ;                   ;                               ;                                           ;                       ;                               ;<br>                                     ;summary:$solrIndexedType                                      ;                                                                                                       ;       ;                               ;                   ;                       ;               ;                        ;                         ;                   ;                               ;                                           ;                       ;                               ;<br><br><br>

Accepted Solutions (0)

Answers (1)

Answers (1)

a_e_dubey
Active Participant
0 Kudos

Hello sargis.minasyan Please note that this default and suggestion query template configuration are being used when request is sent to Solr. And to personalize query and other solr configuration SAP given option to pick Query Template i.e Default or Suggestion.

To summarize your case, if you see below code which fetch suggestion of products to display in suggestion box. And in suggestion box need only products basic details only no facets properties required for Suggestion profile.

SearchPageController:

public AutocompleteResultData getAutocompleteSuggestions(@PathVariable final String componentUid,
			@RequestParam("term") final String term) throws CMSItemNotFoundException
	{
		final AutocompleteResultData resultData = new AutocompleteResultData();

		final SearchBoxComponentModel component = (SearchBoxComponentModel) cmsComponentService.getSimpleCMSComponent(componentUid);

		if (component.isDisplaySuggestions())
		{
			resultData.setSuggestions(subList(productSearchFacade.getAutocompleteSuggestions(term), component.getMaxSuggestions()));
		}

		if (component.isDisplayProducts())
		{
			resultData.setProducts(subList(productSearchFacade.textSearch(term, SearchQueryContext.SUGGESTIONS).getResults(),
					component.getMaxProducts()));
		}

		return resultData;
	}
But if you want to fetch other properties as well as facets you need add solrindex properties into SUGGESTION profile using below impex example:
 # Other search query facets
INSERT_UPDATE SolrSearchQueryProperty;indexedProperty(name, solrIndexedType(identifier))[unique=true];facet[default=true];facetType(code);priority;facetDisplayNameProvider;facetSortProvider;facetTopValuesProvider;includeInResponse[default=true];searchQueryTemplate(name, indexedType(identifier))[unique=true][default=DEFAULT:$solrIndexedType]
									 ;price:$solrIndexedType										 ;					 ;MultiSelectOr	 ;4000	  ;						   						;				 			  ;defaultTopValuesProvider	;;
									 ;style:$solrIndexedType										 ;					 ;MultiSelectOr	 ;-1	  ;						   						;				 			  ;							;;
									 ;swatchColors:$solrIndexedType									 ;					 ;MultiSelectOr	 ;2500	  ;colorFacetDisplayNameProvider				;			 				  ;						  	;;
									 ;size:$solrIndexedType											 ;					 ;MultiSelectOr	 ;2000	  ;						   						;sizeAttributeSortProvider	  ;				  			;;
									 ;availableInStores:$solrIndexedType							 ;					 ;MultiSelectOr	 ;10000	  ;apparelPointOfServiceFacetDisplayNameProvider;distanceAttributeSortProvider;							;;
I hope this will help you.
a_e_dubey
Active Participant
0 Kudos

DEFAULT profile show facets because SolrSearchQueryProperty has all index properties configuration OOTB. So you replace in header with SUGGESTION instead of DEFAULT. It will work.