Introduced in Feature Pack 2

Adding query or filter query parameters to the final Solr query

You can add query or filter query parameters to the final Solr query to restrict the documents that can be returned.

Query parameters influence relevancy scores, as they are considered mandatory queries. However, filter queries do not influence relevancy scores. Filter queries can be useful for speeding up complex queries, since they are cached independently from the main query.

Procedure

  1. Add a custom expression in the getData tag in the SearchSetup.jspf file:
    • WC_installdir/Stores.war/widgetdir/Common/SearchSetup.jspf
    • WebSphere Commerce DeveloperWCDE_installdir\workspace\Stores\WebContent\widgetdir\Common\SearchSetup.jspf
    For example, to remove BundleBean from searches:
    
    <c:set var="customExpr" value="-catenttype_id_ntk_cs:BundleBean" scope="request"/>
     
        <wcf:getData type="com.ibm.commerce.catalog.facade.datatypes.CatalogNavigationViewType" var="catalogNavigationView"
            expressionBuilder="${navigationView}" scope="request" varShowVerb="showCatalogNavigationView"
            maxItems="${pageSize}" recordSetStartNumber="${beginIndex}" scope="request">
            <wcf:param name="searchProfile" value="${searchProfile}" />
            <wcf:param name="searchTerm" value="${newSearchTerm}" />
            <wcf:param name="intentSearchTerm" value="${intentSearchTerm}" />
            <wcf:param name="searchType" value="${searchType}" />
            <wcf:param name="searchSource" value="${WCParam.searchSource}" />
            <wcf:param name="metaData" value="${WCParam.metaData}" />
            <wcf:param name="orderBy" value="${WCParam.orderBy}" />
            <c:forEach var="facetValue" items="${paramValues.facet}">
                <wcf:param name="facet" value="${facetValue}" />
            </c:forEach>
            <wcf:param name="advancedFacetList" value="${newAdvancedFacetList}"/>
            <wcf:param name="categoryId" value="${currentCategoryId}" />
            <wcf:param name="filterTerm" value="${newFilterTerm}" />
            <wcf:param name="filterType" value="${WCParam.filterType}" />
            <wcf:param name="filterFacet" value="${WCParam.filterFacet}" />
            <wcf:param name="manufacturer" value="${newManufacturer}" />
            <wcf:param name="minPrice" value="${WCParam.minPrice}" />
            <wcf:param name="maxPrice" value="${WCParam.maxPrice}" />
            <wcf:param name="customExpr" value="${customExpr}" />
            <wcf:contextData name="storeId" value="${WCParam.storeId}" />
            <wcf:contextData name="catalogId" value="${WCParam.catalogId}" />
    
        </wcf:getData>
    
  2. Add the query or filter query in the get-data-config.xml file:
    • WC_installdir/wc.ear/Stores.war/WEB-INF/config/com.ibm.commerce.catalog-fep/get-data-config.xml
    In the getCatalogNavigationView expression builder, add either the query or filter query:
    • To add a query, update the expression builder to include _wcf.search.expr
    • To add a query filter, update the expression builder to include _wcf.search.internal.filterquery
    For example, to update the expression builder with a query filter:
    
    <expression-builder>
            <name>getCatalogNavigationView</name>
            <data-type-name>CatalogNavigationView</data-type-name>
            <expression-template>{_wcf.ap='$accessProfile$';_wcf.search.profile='$searchProfile$';
    _wcf.search.term='$searchTerm$';_wcf.search.intent.term='$intentSearchTerm$';
    _wcf.search.originalterm='$originalSearchTerm$';_wcf.search.category='$categoryId$';
    _wcf.search.internal.filterquery='$customExpr$';_wcf.search.type='$searchType$';
    _wcf.search.exclude.term='$filterTerm$';_wcf.search.exclude.type='$filterType$';
    _wcf.search.manufacturer='$manufacturer$';_wcf.search.price.minimum='$minPrice$';
    _wcf.search.price.maximum='$maxPrice$';_wcf.search.facet='$facet$';
    _wcf.search.advanced.facet='$advancedFacetList$';_wcf.search.exclude.facet='$filterFacet$';
    _wcf.search.sort='$orderBy$';_wcf.search.meta='$metaData$';_
    wcf.search.source='$searchSource$'}/CatalogNavigationView</expression-template>
            <param>