Search index schema customization file x-schema.xml

Adding new fields into the index schema requires modifying the x-schema.xml file to add the new index field. Typically, an existing index is updated to add new fields (local index). In other instances, it is recommended to extend the product index by creating an index as an extension of an existing index (extension index).

The following snippet is a sample index field for the catentry_id in the CatalogEntry index:

<field name="catentry_id" type="string" indexed="true" stored="true" required="true" multiValued="false"/>

HCL Commerce field types

In addition to native Solr field types, HCL Commerce introduces some custom field types. For example:
Tokenized text for searching.
Non-tokenized text for sorting and faceting.
Non-tokenized text for not case-sensitive sorting.
Spell checking for text fields.

Valid attributes for fields

The following list summarizes the valid attributes for fields;
(Required) The name for the field.
(Required) The name of a previously defined type from the <types> section.
Indicates whether the field should be indexed (searchable or sortable).
Indicates whether the field should be retrievable.
Indicates whether the field should be stored by using gzip compression.
This attribute applies only if the field type is compressible. For the standard field types, only TextField and StrField are compressible.
Indicates whether the field can contain multiple values per document.
Indicates whether to omit the norms that are associated with this field. Setting to true disables length normalization and index-time boosting for the field, and saves some memory.
Only full-text fields or fields that require index-time boosting need norms.
Indicates whether to store the term vector for a field.
When using MoreLikeThis, fields that are used for similarity should be stored for best performance.
Note: When you work with an extension index, be aware of the following guidelines when you use the indexed and stored fields:
  • If an extension index is used as a filter index, where the field is always included in a filter query and the column value is irrelevant, set the stored value to false.

    Otherwise, if the extension index always works to supplement meta information to the master core, such as inventory, set the stored value to true.

  • If facets are required by a field in the extension index, set the indexed value to true.
  • Setting the stored field as false might save index storage space.
  • If a column copies to a dest column, it is unnecessary to set stored as true.

HCL Commerce text field naming convention

The following naming convention is followed for text fields in HCL Commerce Search:
Tokenized and not case-sensitive for example, mfName.
Tokenized and case-sensitive for example, mfName_cs.
Non-tokenized and not case-sensitive for example, mfName_ntk.
Non-tokenized and case-sensitive for example, catenttype_id_ntk_cs.
  • HCL Commerce Search requires one search index per language. Whenever the search schema is changed and the index is regenerated, it must be performed for every language.
  • To view the customization under the workspace preview, any changes that are made to the base x-schema.xml file must also be applied to the workspace x-schema.xml file.

Local index

The index fields are defined in the fields section of the x-schema.xml file in the following directory:
  • workspace_dir\components\foundation\subcomponents\search\solr\home\template\CatalogEntry\conf\locale\locale
Note: The x-schema.xml file is locale-specific, as some data types use locale-specific tokenizers.
To customize the index schema, modify the x-schema.xml file. The following configuration is an example of adding the catalog entry customizable fields, field1, field3, and field5 to the CatalogEntry index:

<field name="catentry_field1" type="tint" indexed="true" stored="true" required="false" multiValued="false"/> 
<field name="catentry_field3" type="tfloat " indexed="true" stored="true" required="false" multiValued="false"/> 
<field name="catentry_field5" type="wc_text" indexed="true" stored="true" required="false" multiValued="false"/>