Combining minimum match with search term associations (using the Solr expansion algorithm)

We can combine minimum match with search term associations, if you use the Solr synonym expansion algorithm. This option is often used along with the auto-phrase filter to enable multi-word search term associations.

Note: We can also combine minimum match with search term associations by use the run time query expansion algorithm.


Task info

Be aware of the following limitations of this feature:


Procedure

  1. Open the LOBTools\WebContent\config\commerce\catalog\objectDefinitions\SearchTermAssociationsPrimaryObjectDefinition.def file for editing:

  2. Uncomment the following section:

      <!—Comments out the following definition to prevent generating "synonyms.txt" for solr server.-->
         <PostSaveService url="/cmc/PublishSearchTermAssociations">
            <ServiceParam name="storeId"/>
         </PostSaveService>

  3. Save our changes and close the file.

  4. Open the following file for editing:

    • solrhome/MC_masterCatalogId/locale_name/Catalogentry/conf/schema.xml

    If we want unstructured content to behave in the same way, also open the following file for editing:

    • solrhome/MC_masterCatalogId/locale_name/Catalogentry/conf/unstructured/schema.xml

  5. Add the following filter class snippet to the file, within the wc_text query analyzer block, before the SnowballPorterFilterFactory filter, and after the WhitespaceTokenizerFactory:

      <filter class="solr.SynonymFilterFactory" synonyms="synonyms.txt" ignoreCase="true" expand="true"/>

    If we are updating the unstructured content schema.xml file, make the following update:

      <filter class="solr.SynonymFilterFactory" synonyms="../../synonyms.txt" ignoreCase="true" expand="true"/>

  6. Save our changes and close the file.

  7. Update all versions of the WebSphere Commerce Search configuration file (wc-search.xml):

    • On the WC EAR: workspace_dir/WC/xml/config/com.ibm.commerce.catalog-ext/wc-search.xml

    • On the Search EAR: Search_eardir/xml/config/com.ibm.commerce.catalog-ext/wc-search.xml

    Add synonym="/conf/synonyms.txt" into the CatalogEntry core.

      <_config:core catalog="10001" indexName="CatalogEntry"
         language="en_US" name="MC_10001_CatalogEntry_en_US"
         path="/MC_10001/en_US/CatalogEntry" serverName="BasicConfiguration" synonym="/conf/synonyms.txt"/>

    If we want unstructured content to behave in the same way, update the UnstructuredContent core.

      <_config:core catalog="10001" indexName="UnstructuredContent"
         language="en_US" name="MC_10001_CatalogEntry_Unstructured_en_US"
         path="/MC_10001/en_US/CatalogEntry/unstructured" serverName="BasicConfiguration" synonym="/conf/synonyms.txt"/>

    See Search configuration.

  8. Ensure that the synonyms.txt file exists in the following directory: solrhome/MC_masterCatalogId/locale_name/Catalogentry/conf Important: The Management Center automatically updates the synonyms.txt only on the WebSphere Commerce server in the preceding location.

    If the WebSphere Commerce and search servers are in separate nodes in the authoring environment, ensure that the synonyms.txt file exists on both the WebSphere Commerce and search nodes.

    Then, synchronize the search server's version of the file with the updated WebSphere Commerce version of the file. That is, the synonyms.txt file must be transferred from the WebSphere Commerce server to the search server after each search term association update in the Management Center. Doing so ensures that changes made in the WebSphere Commerce authoring environment are also reflected on the search server.

  9. To synchronizing Solr configuration files, such as stopwords.txt, x-schema.xml and synonyms.txt between master and subordinate servers, we can simply deploy the same Docker images on each node. For each master/subordinate combination, modify the polling interval and Master URL to customize Solr behavior. We cannot change the solrconfig.xml configuration file directly; instead, use one of the methods described in Extending the solrconfig.xml file to change the variables. For example, we can change the value of the polling interval via the solr.replication.pollInterval parameter in the SRCHCONFEXT database table. The Master URL can similarly be customized by changing the solr.master.server.url parameter. For example:

      update srchconfext set config='solr.master.server.url=master_hostname:master_https_port, solr.replication.pollInterval=00:00:10' where srchconfext_id=srchconfext_id;

    where master_hostname and master_https_port are the values specific to the environment. If instead you customize solrconfig.xml by editing the jvm.options file (as described in Extending the solrconfig.xml file), add the following lines to jvm.options:

      -Dsolr.master.server.url=master_hostname:master_https_port 
      -Dsolr.replication.pollInterval=00:00:10

  10. We can transfer existing search term associations from the Management Center to the synonyms.txt file. To do so, trigger a minor change in either the synonym or replacement terms then save your change.