Example: Indexing additional fields for attributes
In this example, WebSphere Commerce search is customized to index 10 more attribute string fields.
Procedure
- Configure the search preprocessor.
-
Go to the following directory:
- WCDE_installdir/search/pre-processConfig/MC_masterCatalogId/development_db
- WC_installdir/instances/instance_name/search/pre-processConfig/MC_masterCatalogId/target_db
-
Create a custom preprocess configuration file and call it
wc-dataimport-preprocess-custom-clsattribute.xml.
Note:
- Your table name must start with an X to avoid conflict with the default WebSphere Commerce tables.
- Do not change existing preprocess configuration files. Newly created custom preprocess configuration files must start with wc-dataimport-preprocess and end in .xml for example, wc-dataimport-preprocess-XXXXX.xml, wc-dataimport-preprocess-custom-clsattribute.xml.
-
Go to the following directory:
- Add new fields into the CLSATTRSRCHCONF table:The newly added columns and table name prefix from the previous section must be added into the CLSATTRSRCHCONF table.
insert into clsattrsrchconf values (201, 10101, 'XF_CAS_F1', null, -1, 'STRING', 'XI_CASTB1_0_', null, 1); insert into clsattrsrchconf values (202, 10101, 'XF_CAS_F2', null, -1, 'STRING', 'XI_CASTB1_0_', null, 1); insert into clsattrsrchconf values (203, 10101, 'XF_CAS_F3', null, -1, 'STRING', 'XI_CASTB1_0_', null, 1); insert into clsattrsrchconf values (204, 10101, 'XF_CAS_F4', null, -1, 'STRING', 'XI_CASTB1_0_', null, 1); insert into clsattrsrchconf values (205, 10101, 'XF_CAS_F5', null, -1, 'STRING', 'XI_CASTB1_0_', null, 1); insert into clsattrsrchconf values (206, 10101, 'XF_CAS_F6', null, -1, 'STRING', 'XI_CASTB1_0_', null, 1); insert into clsattrsrchconf values (207, 10101, 'XF_CAS_F7', null, -1, 'STRING', 'XI_CASTB1_0_', null, 1); insert into clsattrsrchconf values (208, 10101, 'XF_CAS_F8', null, -1, 'STRING', 'XI_CASTB1_0_', null, 1); insert into clsattrsrchconf values (209, 10101, 'XF_CAS_F9', null, -1, 'STRING', 'XI_CASTB1_0_', null, 1); insert into clsattrsrchconf values (210, 10101, 'XF_CAS_F10', null, -1, 'STRING', 'XI_CASTB1_0_', null, 1);
- Populate the CLSATTRSRCHCONF table:
update clsattrsrchconf set attrname='SIZE' where CLSATTRSRCHCONF_ID = 201; update clsattrsrchconf set attrname='COLOR' where CLSATTRSRCHCONF_ID = 202;
This sample indexes size and color attributes based on data that is inserted in the previous step.
- Populate the SRCHATTR
and SRCHATTRPROP tables.
INSERT INTO srchattr (SRCHATTR_ID, INDEXSCOPE, INDEXTYPE, IDENTIFIER, OPTCOUNTER) VALUES (1029, '10101', 'CatalogEntry', '_cat.SIZE', 1); INSERT INTO srchattr (SRCHATTR_ID, INDEXSCOPE, INDEXTYPE, IDENTIFIER, OPTCOUNTER) VALUES (1030, '10101', 'CatalogEntry', '_cat.COLOR', 1); INSERT INTO srchattrprop (SRCHATTR_ID, PROPERTYNAME, PROPERTYVALUE, OPTCOUNTER) VALUES (1029, 'facet', 'xf_cas_f1_ntk_cs', 1); INSERT INTO srchattrprop (SRCHATTR_ID, PROPERTYNAME, PROPERTYVALUE, OPTCOUNTER) VALUES (1030, 'facet', 'xf_cas_f2_ntk_cs', 1);
Note: There is a limitation for faceting attributes, where the facet name displayed on storefront is not language-dependent. That is, it displays the content of the IDENTIFIER column of the SRCHATTR table without the prefix. For example, the identifier _cat.SIZE is displayed as SIZE in the storefront for the attribute, regardless of language. -
Preprocess the search index data.
- Query the XI_CASTB1_0_1 table to confirm that the data is populated.
- Configure the Data Import Handler mapping.
-
Go to the following directory:
- WCDE_installdir/search/solr/home
- WC_installdir/instances/instance_name/search/solr/home
This directory contains the Master Catalog folder, in which there are the configurations files for each language. If you have more than one language folders, perform this step for every language.
- Open the MC_masterCatalogId/en_US/CatalogEntry/conf/schema.xml file.
- Locate
<dynamicField name="caf_f*" type="float" indexed="true" stored="true" multiValued="true"/>
and add the following snippet in bold.<!-- Catentry's classic attributes: map to table: ATTRVALUE, ATTRIBUTE --> <dynamicField name="cas_f*" type="wc_text" indexed="true" stored="true" multiValued="true"/> <dynamicField name="cai_f*" type="int" indexed="true" stored="true" multiValued="true"/> <dynamicField name="caf_f*" type="float" indexed="true" stored="true" multiValued="true"/> <!-- Newly added attribute dictionary attribute. --> <dynamicField name="xf_cas_f*" type="wc_text" indexed="true" stored="true" multiValued="true"/> <field name="xf_cas_f1_ntk_cs" type="string" indexed="true" stored="true" multiValued="true"/> <field name="xf_cas_f2_ntk_cs" type="string" indexed="true" stored="true" multiValued="true"/> <field name="xf_cas_f3_ntk_cs" type="string" indexed="true" stored="true" multiValued="true"/> <field name="xf_cas_f4_ntk_cs" type="string" indexed="true" stored="true" multiValued="true"/> <field name="xf_cas_f5_ntk_cs" type="string" indexed="true" stored="true" multiValued="true"/> <field name="xf_cas_f6_ntk_cs" type="string" indexed="true" stored="true" multiValued="true"/> <field name="xf_cas_f7_ntk_cs" type="string" indexed="true" stored="true" multiValued="true"/> <field name="xf_cas_f8_ntk_cs" type="string" indexed="true" stored="true" multiValued="true"/> <field name="xf_cas_f9_ntk_cs" type="string" indexed="true" stored="true" multiValued="true"/> <field name="xf_cas_f10_ntk_cs" type="string" indexed="true" stored="true" multiValued="true"/>
- Locate
<copyField source="adf_f*" dest="defaultSearch"/>
and add the following snippet in bold.<!-- Copy fields for default search field --> <copyField source="name" dest="defaultSearch"/> <copyField source="shortDescription" dest="defaultSearch"/> <copyField source="partNumber_ntk" dest="defaultSearch"/> <copyField source="keyword" dest="defaultSearch"/> <copyField source="cas_f*" dest="defaultSearch"/> <copyField source="cai_f*" dest="defaultSearch"/> <copyField source="caf_f*" dest="defaultSearch"/> <copyField source="ads_f*" dest="defaultSearch"/> <copyField source="adi_f*" dest="defaultSearch"/> <copyField source="adf_f*" dest="defaultSearch"/> <copyField source="xf_cas_f*" dest="defaultSearch"/>
- Save your changes.
- Open the MC_masterCatalogId/en_US/CatalogEntry/conf/wc-data-config.xml file.
- Locate
<document name="CatalogEntry">
forentity name="Product"
,name="Bundle"
andname="Others"
, for both thequery
anddeltaImportQuery
sections. - Add the following columns and tables in bold to the select SQL:
SELECT CATENTRY.CATENTRY_ID,CATENTRY.MEMBER_ID,CATENTRY.CATENTTYPE_ID,CATENTRY.PARTNUMBER,CATENTRY.MFPARTNUMBER,CATENTRY.MFNAME, CATENTRY.BUYABLE, STORECENT.STOREENT_ID, CATENTDESC.NAME,CATENTDESC.SHORTDESCRIPTION,CATENTDESC.LONGDESCRIPTION,CATENTDESC.THUMBNAIL,CATENTDESC.FULLIMAGE, CATENTDESC.KEYWORD, CATENTDESC.PUBLISHED, TI_DPGROUP.CATGROUP DPCATGROUP, TI_APGROUP.CATGROUPS APCATGROUP, TI_PRODUCTSET.PRODUCTSET, TI_OFFERPRICE.PRICE_USD, TI_OFFERPRICE.PRICE_EUR, TI_OFFERPRICE.PRICE_CAD, TI_OFFERPRICE.PRICE_CNY, TI_OFFERPRICE.PRICE_JPY, TI_OFFERPRICE.PRICE_KRW, TI_OFFERPRICE.PRICE_BRL, TI_OFFERPRICE.PRICE_TWD, TI_OFFERPRICE.PRICE_PLN, TI_OFFERPRICE.PRICE_PLN, TI_OFFERPRICE.PRICE_RON, TI_OFFERPRICE.PRICE_EGP, TI_OFFERPRICE.PRICE_GBP, TI_DPCATENTRY.CATENTRY_PARENT, TI_CATALOG.CATALOG PARENT_CATALOG_ID, TI_CATGPENREL.SEQUENCE, TI_CASTB1.CAS_F1 CAS_F1ATTR, TI_CASTB1.CAS_F2 CAS_F2ATTR, TI_CASTB1.CAS_F3 CAS_F3ATTR,TI_CASTB1.CAS_F4 CAS_F4ATTR,TI_CASTB1.CAS_F5 CAS_F5ATTR, TI_CASTB1.CAS_F6 CAS_F6ATTR,TI_CASTB1.CAS_F7 CAS_F7ATTR, TI_CASTB1.CAS_F8 CAS_F8ATTR,TI_CASTB1.CAS_F9 CAS_F9ATTR,TI_CASTB1.CAS_F10 CAS_F10ATTR, TI_CASTB1.CAS_F11 CAS_F11ATTR,TI_CASTB1.CAS_F12 CAS_F12ATTR,TI_CASTB1.CAS_F13 CAS_F13ATTR,TI_CASTB1.CAS_F14 CAS_F14ATTR,TI_CASTB1.CAS_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B1.ADF_F7, TI_ADFTB1.ADF_F8, TI_ADFTB1.ADF_F9, TI_ADFTB1.ADF_F10
Append the table join clause in bold:FROM CATENTRY INNER JOIN TI_CATENTRY_0 TI_CATENTRY ON (CATENTRY.CATENTRY_ID=TI_CATENTRY.CATENTRY_ID) LEFT OUTER JOIN STORECENT ON (CATENTRY.CATENTRY_ID=STORECENT.CATENTRY_ID) LEFT OUTER JOIN CATENTDESC ON (CATENTDESC.CATENTRY_ID=CATENTRY.CATENTRY_ID AND CATENTDESC.LANGUAGE_ID=-1) LEFT OUTER JOIN TI_DPGROUP_0 TI_DPGROUP ON (CATENTRY.CATENTRY_ID=TI_DPGROUP.CATENTRY_ID) LEFT OUTER JOIN TI_APGROUP_0 TI_APGROUP ON (CATENTRY.CATENTRY_ID=TI_APGROUP.CATENTRY_ID) LEFT OUTER JOIN TI_PRODUCTSET_0 TI_PRODUCTSET ON (CATENTRY.CATENTRY_ID=TI_PRODUCTSET.CATENTRY_ID) LEFT OUTER JOIN TI_OFFERPRICE_0 TI_OFFERPRICE ON (CATENTRY.CATENTRY_ID=TI_OFFERPRICE.CATENTRY_ID) LEFT OUTER JOIN TI_DPCATENTRY_0 TI_DPCATENTRY ON (CATENTRY.CATENTRY_ID=TI_DPCATENTRY.CATENTRY_ID) LEFT OUTER JOIN TI_CATALOG_0 TI_CATALOG ON (CATENTRY.CATENTRY_ID=TI_CATALOG.CATENTRY_ID) LEFT OUTER JOIN TI_CATGPENREL_0 TI_CATGPENREL ON (CATENTRY.CATENTRY_ID=TI_CATGPENREL.CATENTRY_ID) LEFT OUTER JOIN TI_CASTB1_0_1 TI_CASTB1 ON (CATENTRY.CATENTRY_ID=TI_CASTB1.CATENTRY_ID) LEFT OUTER JOIN TI_CAITB1_0_1 TI_CAITB1 ON (CATENTRY.CATENTRY_ID=TI_CAITB1.CATENTRY_ID) LEFT OUTER JOIN TI_CAFTB1_0_1 TI_CAFTB1 ON (CATENTRY.CATENTRY_ID=TI_CAFTB1.CATENTRY_ID) LEFT OUTER JOIN XI_LISTPRICE_0 XI_LISTPRICE ON (CATENTRY.CATENTRY_ID=XI_LISTPRICE.CATENTRY_ID) LEFT OUTER JOIN TI_ADSTB1_0_1 TI_ADSTB1 ON (CATENTRY.CATENTRY_ID=TI_ADSTB1.CATENTRY_ID) LEFT OUTER JOIN TI_ADITB1_0_1 TI_ADITB1 ON (CATENTRY.CATENTRY_ID=TI_ADITB1.CATENTRY_ID) LEFT OUTER JOIN TI_ADFTB1_0_1 TI_ADFTB1 ON (CATENTRY.CATENTRY_ID=TI_ADFTB1.CATENTRY_ID)
Add the field mapping before<field column="cas_f30_ntk_cs" splitBy=";" sourceColName="CAS_F30ATTR"/>
:<field column="cas_f29" splitBy=";" sourceColName="CAS_F29ATTR"/> <field column="cas_f29_ntk_cs" splitBy=";" sourceColName="CAS_F29ATTR"/> <field column="CAS_F30ATTR" clob="true"/> <field column="cas_f30" splitBy=";" sourceColName="CAS_F30ATTR"/> <field column="cas_f30_ntk_cs" splitBy=";" sourceColName="CAS_F30ATTR"/> <!-- newly added classic attribute field --> <field column="XF_CAS_F1ATTR" clob="true"/> <field column="xf_cas_f1" splitBy=";" sourceColName="XF_CAS_F1ATTR"/> <field column="xf_cas_f1_ntk_cs" splitBy=";" sourceColName="XF_CAS_F1ATTR"/> <field column="XF_CAS_F2ATTR" clob="true"/> <field column="xf_cas_f2" splitBy=";" sourceColName="XF_CAS_F2ATTR"/> <field column="xf_cas_f2_ntk_cs" splitBy=";" sourceColName="XF_CAS_F2ATTR"/> <field column="XF_CAS_F3ATTR" clob="true"/> <field column="xf_cas_f3" splitBy=";" sourceColName="XF_CAS_F3ATTR"/> <field column="xf_cas_f3_ntk_cs" splitBy=";" sourceColName="XF_CAS_F3ATTR"/> <field column="XF_CAS_F4ATTR" clob="true"/> <field column="xf_cas_f4" splitBy=";" sourceColName="XF_CAS_F4ATTR"/> <field column="xf_cas_f4_ntk_cs" splitBy=";" sourceColName="XF_CAS_F4ATTR"/> <field column="XF_CAS_F5ATTR" clob="true"/> <field column="xf_cas_f5" splitBy=";" sourceColName="XF_CAS_F5ATTR"/> <field column="xf_cas_f5_ntk_cs" splitBy=";" sourceColName="XF_CAS_F5ATTR"/> <field column="XF_CAS_F6ATTR" clob="true"/> <field column="xf_cas_f6" splitBy=";" sourceColName="XF_CAS_F6ATTR"/> <field column="xf_cas_f6_ntk_cs" splitBy=";" sourceColName="XF_CAS_F6ATTR"/> <field column="XF_CAS_F7ATTR" clob="true"/> <field column="xf_cas_f7" splitBy=";" sourceColName="XF_CAS_F7ATTR"/> <field column="xf_cas_f7_ntk_cs" splitBy=";" sourceColName="XF_CAS_F7ATTR"/> <field column="XF_CAS_F8ATTR" clob="true"/> <field column="xf_cas_f8" splitBy=";" sourceColName="XF_CAS_F8ATTR"/> <field column="xf_cas_f8_ntk_cs" splitBy=";" sourceColName="XF_CAS_F8ATTR"/> <field column="XF_CAS_F9ATTR" clob="true"/> <field column="xf_cas_f9" splitBy=";" sourceColName="XF_CAS_F9ATTR"/> <field column="xf_cas_f9_ntk_cs" splitBy=";" sourceColName="XF_CAS_F9ATTR"/> <field column="XF_CAS_F10ATTR" clob="true"/> <field column="xf_cas_f10" splitBy=";" sourceColName="XF_CAS_F10ATTR"/>
- Save the changes and close the file.
-
Go to the following directory:
- Restart the WebSphere Commerce search server.
- Run the di-buildindex utility.
- Verify the data:
- http://localhost/solr/MC_10101_CatalogEntry_en_US/select?q=*:*
- http://yoursolrserverhost:3737/solr/MC_10101_CatalogEntry_en_US/select?q=*:*