Combining minimum match with search term associations (using the Solr expansion algorithm)
You 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.
About this task
- A single synonyms.txt file per master catalog is supported. The same synonyms.txt file is shared by all extended sites.
- Multiple word synonyms or replacement terms are not supported.
- If the WebSphere Commerce and search servers are on separate nodes in the authoring environment, transfer the synonyms.txt file from the WebSphere Commerce server to the search server. Repeat this process after every Management Center search term association update. Transfer the file by using NFS file transfer or manually copying the file. The file is then replicated to the subordinate servers in the production environment.
Procedure
-
Open the following file for editing:
- LOBTools.war/config/commerce/catalog/objectDefinitions/SearchTermAssociationsPrimaryObjectDefinition.def
- LOBTools\WebContent\config\commerce\catalog\objectDefinitions\SearchTermAssociationsPrimaryObjectDefinition.def
-
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>
- Save your changes and close the file.
-
Open the following file for editing:
- solrhome/MC_masterCatalogId/locale_name/Catalogentry/conf/schema.xml
If you 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
-
Add the following filter class snippet to the file, within the
wc_text
query analyzer block, before theSnowballPorterFilterFactory
filter, and after theWhitespaceTokenizerFactory
:<filter class="solr.SynonymFilterFactory" synonyms="synonyms.txt" ignoreCase="true" expand="true"/>
If you are updating the unstructured content schema.xml file, make the following update:<filter class="solr.SynonymFilterFactory" synonyms="../../synonyms.txt" ignoreCase="true" expand="true"/>
- Save your changes and close the file.
-
Update all versions of the WebSphere Commerce Search configuration file
(wc-search.xml):
- On the WC EAR: WC_eardir/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 you 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"/>
For more information, see Search configuration.
-
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 your 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.
-
You can use Solr replication to replicate your search term association changes into production.
Update the location's
solrhome/MC_masterCatalogId/locale_name/indextype/conf/solrconfig.xml:
In the master server's Solr configuration file, uncomment and update the following snippet:
3) Search server in staging Reference configuration for search server in a staging environment <requestHandler name="/replication" class="solr.ReplicationHandler"> <lst name="master"> <str name="replicateAfter">commit</str> <str name="replicateAfter">startup</str> <str name="confFiles">schema.xml,stopwords.txt,synonyms.txt</str> </lst> </requestHandler>
In the subordinate server's Solr configuration file, uncomment and update the following snippet:2) Search repeater Reference configuration for search repeater (as master) in a production environment and (as slave) in a staging environment Note: hostname for masterURL is the hostname of the search server in the staging environment; the slave section is optional if not using with a staging environment. <requestHandler name="/replication" class="solr.ReplicationHandler"> <lst name="master"> <str name="replicateAfter">commit</str> <str name="replicateAfter">startup</str> <str name="confFiles">schema.xml,stopwords.txt,synonyms.txt</str> </lst> <lst name="slave"> <str name="masterUrl">http://hostname:port/solr/MC_masterCatalogId_CatalogEntry_locale_name/replication</str> <str name="pollInterval">00:00:10</str> </lst> </requestHandler>
These changes automatically update the subordinate server's synonyms.txt file with the master's file every 10 seconds.
For more information, see Search configuration properties in the Solr configuration file (solrconfig.xml).
- You 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.