Enable MultipleQueryComponent and MultipleFacetComponent in Version 9

MultipleQueryComponent and MultipleFacetComponent, which were used to join or filter subcores in WebSphere Commerce Version 7, are disabled by default in WebSphere Commerce version 9.0.0.0+. We can re-enable these functions if you require them.


Task info

From Version 9.0.0.0+, WebSphere Commerce Search uses Solr-native QueryComponent and FacetComponent and additional SolrJoin functions to perform join or filter operations on extended indexes. The customized MultipleQueryComponent and MultipleFacetComponent functions can do the following:

Although these are powerful functions, there are some limitations with SolrJoin. For example, we cannot use boost with extended indexes, and Solr functions you customized for previous versions of the product might not work. QueryComponent and facetComponent are enabled via the following component definition in the solrconfig.xml configuration file.

Use the following procedure to revert to the default SolrSearchMultipleQueryComponent or create our own customized QueryComponent like, SimpleSearchMultipleQueryComponent.


Procedure

  1. Opttional: If to create our own functions, create new SimpleSearchMultipleQueryComponent and SimpleFacetComponent definitions. Extend the SolrSearchMultipleQueryComponent, SolrSearchMultipleFacetComponent as needed in the x-solrconfig.xml file, which is located in the search-config-ext project. This step is not needed if we want only to switch back to Commerce OOB SolrSearchMultipleQueryComponent/ SolrSearchMultipleFacetComponent. See Extending the solrconfig.xml file.

  2. Opttional: SolrSearchMultipleQueryComponent and SolrSearchMultipleFacetComponent are registered for the CatalogEntry core as wc-query and wc-facet in the solrconfig.xml configuration file. To use our own SimpleSearchMultipleQueryComponent for simple-query purposes, we must also register it in x-solrconfig.xml as follows:

      <searchComponent name="simple_query" class="com.mycomp.solr.component.SimpleSearchMultipleQueryComponent">
      <str name="referenceField">catentry_id</str>
      <arr name="subCores">
      </arr>
      </searchComponent>
      
      <searchComponent name="simple_facet" class="com.mycomp.solr.component.SimpleFacetComponent" />

    Again, if we want only to revert to the pre-Version 9 SolrSearchMultipleQueryComponent and SolrSearchMultipleFacetComponent, this step is not needed.

  3. Enable ThreadLRUCache, SolrSearchMultipleQueryComponent and SolrSearchMultipleFacetComponent for the Solr engine. QueryComponent relies on documentCache to cache Lucene Document objects, while by default solr.LRUCache was registered in solrconfig.xml as documentCache. SolrSearchMultipleQueryComponent relies on the WebSphere Commerce customized ThreadLRUCache to map the docId between the master core and extended indexes. Therefore, ThreadLRUCache registration is also needed for the Solr engine. Run a query on the database client once for each of the three components, using the following three definitions for the components:

    • queryComponent=wc_query

    • facetComponent=wc_facet

    • documentCache=ThreadLRUCache

    In this example, wc_query is used to change queryComponent.

      update srchconfext set config='queryComponent=wc_query,facetComponent=wc_facet,documentCache=com.ibm.commerce.foundation.internal.server.services.search.component.solr.ThreadLRUCache' 
      where indextype='CatalogEntry' and indexsubtype='Structured';

    To use customized simple_query, simple_facet and ThreadLRUCache:

      update srchconfext set config='queryComponent=simple_query,facetComponent=simple_facet,documentCache=com.ibm.commerce.foundation.internal.server.services.search.component.solr.ThreadLRUCache' where indexType='CatalogEntry' and indexsubtype='Structured';

    During search server restart, the search server will synchronize the properties defined in such configuration columns and write them into the x-core.properties properties file under the CatalogEntry core. If you open the x-core.properties file we can find the entries that enable wc_query:

      queryComponent=wc_query
      facetComponent=wc_facet
      documentCache=com.ibm.commerce.foundation.internal.server.services.search.component.solr.ThreadLRUCache

    and the entries that enable simple_query:

      queryComponent=simple_query
      facetComponent=simple_facet
      documentCache=com.ibm.commerce.foundation.internal.server.services.search.component.solr.ThreadLRUCache

    Note: MultipleQueryComponent requires sufficient cache space to hold the docId map for both the CatalogEntry core and extended core. Tune solr.documentCache.size and solr.documentCache.initialSize to fit your index size. Set these sizes in the srchconfext database as well to make it take effect on V9.

  4. To disable SearchCatalogEntryExtensionIndexPostprocessor for the specified search profile in search-config-ext/src/runtime/config/com.ibm.commerce.search/wc-search.xml, open the file for editing and add the following configuration settings.

      <_config:postprocessor classname="com.ibm.commerce.search.internal.expression.postprocessor.SearchCatalogEntryExtensionIndexPostprocessor" enabled="false" /> 

    Also, to define a field from the extended index as a result field, add this field in the query section, where price_* is an example field:

      <_config:result> 
              <_config:field name="price_*"/> 
      </_config:result>         

    To sort a field from extended index, add this field into the sort section, as in the following example.

       
      <_config:sort> 
                <_config:field name="3" value="price_* asc"/> 
      </_config:sort> 

  5. Save and close the file.

  6. Restart the Search server, and follow the WCB and CI/CD process to deploy our changes to the runtime Docker container.


Results

We can now use MultipleQueryComponent and MultipleFacetComponent as you used them in Version 7.