HCL Commerce Version 9.1.12.0 or later

Sequencing search results using sales rank

This tutorial demonstrates how to create a new custom index to house each product’s sales rank. You will make use of a custom Ingest connector to copy updated sales ranks to the product index incrementally. You will then customize a search profile in the Query service to use this sales rank to sort the term search results.

Before you begin

Ensure that you have downloaded the sample JSON template files that you will use to create your new custom index.In the database, you will use CATENTRY.FIELD1, which is a numeric field.

About this task

In this tutorial you will insert sales rank data into a database table, create a rank connector, populate sales rank into product index, and update the search profile to include a new sort option.
Note: Sorting or sequencing, and search result ranking (ordering of results by relevancy scoring) are not compatible actions. Sales rank sequencing should be considered as a secondary sorting option to the default search relevancy ranking typically used for search results.

Procedure

  1. Create a rank connector.
    Depending on whether you are updating the Auth or Live environment, open the corresponding auth-rank-connector.json or live-rank-connector.json descriptor template and fill in the following settings which are specific to your environment:
    • Review the rank index schema definition and update it if necessary.
    • Update the SQL in ingest.database.sql for retrieving the sales rank data. For example:
      SELECT FIELD1, CATENTRY_ID FROM CATENTRY WHERE FIELD1 IS NOT NULL
      ${paging.prefix} ${param.offset} ${paging.link} ${param.pageSize} ${paging.suffix}
    • Review the index field mappings for storing this data in the rank index:
      CATENTRY_ID - id.catentry
      FIELD1 - custom.rank.numeric
      Note: *.numeric is a dynamic schema pattern that maps to a float data type.
  2. Populate sales rank data into the product index.
    To begin the smart copying to the product index, use the following API, provided your eSite search indexes have already been built.
    • POST /connectors/id/run?storeId=6970&envType=auth&nrt=true where id is the name of the connector, for example auth.rank.
    • This operation only copies new or updated values in the rank index, while unchanged values will be ignored to minimize updates to the product index, which in turn triggers cache invalidation.
  3. Update the search profile.
    To use the new Sales Rank via the Query service, update the following search profile to include an additional sort option:
    • Override the default search profile for performing term searches, HCL_V2_findProductsBySearchTerm, to sort the search results using the custom.rank.numeric field.
    • Use the following API to update the search profile and store it in the Zookeeper configuration registry.
      PUT /search/resources/api/v2/documents/profiles/HCL_V2_findProductsBySearchTerm

Results

You have created a new custom index that houses each product’s sales rank. You can use this index as a secondary sorting option to the default search relevancy ranking typically used for search results.