Build the WebSphere Commerce Search index

We can build the WebSphere Commerce Search index using build index RESTful call. The build index call updates the information in the Master Index using the Data Import Handler (DIH) service to build the index. It builds the index either partially through delta index updates or completely through full index builds. When there are multiple indexes, for example, each language by using its own separate index, the index is built multiple times.


Before beginning


Procedure

  1. Run the build index REST command. The method is POST, and we must include basic authentication in the header, i.e., a spiuser ID and corresponding password. In the development environment, the transaction_server_https_port is the default, so we can specify 443 or leave it blank unless you have changed it. In the runtime environment, the port number is 5443. If we are unsure of the port number, log in to the Transaction server and run the command docker ps to find the port mapping of the ts-app process. Make the POST HTTPS request by using a browser add-on such as example, HttpRequester, for Mozilla Firefox, or Postman, for Google Chrome.

      https://transaction_server_hostname:transaction_server_https_port/wcs/resources/admin/index/dataImport/build?masterCatalogId=masterCatalogId

    Where:

      masterCatalogId
      Required: The ID of the master catalog (for example, 10101).If you do not know the master catalog ID, run the following SQL:

        SQL: select * from catalog where IDENTIFIER='STORE_IDENTIFIER'

      To find the master catalog ID for an Extended Site store:

      1. Find the store ID:

          select * from storeent where IDENTIFIER='STORE_IDENTIFIER'

      2. Use the storeent_id as the store_id in the following SQL to find the catalog asset store ID of this Extended Site store:

          select * from storerel where store_id=XXXXXX and streltyp_id=-4 and relatedstore_id not in (XXXXXX)

        Where XXXXXX is the storeent_id from the SQL in step 1.a when building the search index.

      3. Get the master catalog ID:

          select * from storecat where storeent_id=YYYYYY and mastercatalog='1'

        Where YYYYYY is the relatedstore_id from step 1.b when building the search index.

      indexType
      Optional: Indicates the search engine index to set up for a more granular level of indexing. Valid values:

      • CatalogEntry: Sets up the index for catalog entries in the master catalog.

      • CatalogGroup: Sets up the index for categories in the master catalog.

        If you do not use the indexType parameter, both the CatalogEntry and CatalogGroup indexes are built by default.

      indexSubType
      Optional: Indicates the search engine index subtypes to set up. If you include multiple values, they must be separated by a comma.Valid values:

        Structured
        Sets up the index for structured content.

        Unstructured
        Sets up the index for unstructured content.

        WebContent
        Sets up the index for site content.

        Inventory
        Sets up the index for inventory data.

        Price
        If price index is embedded into the CatalogEntry core, this parameter only calculates price. If the price index is located in a separate Solr index core, this parameter calculates prices and initializes the index for price data.

      If you do not use the indexSubType parameter, the Structured, Unstructured, and WebContent index subtypes are built by default. If you set the indexType to be CatalogGroup, we can set the indexSubType to be Structured. We can set any indexSubType value when you set CatalogEntry to be the indexType value.

      fullBuild
      Optional: A flag that indicates whether it is a full index build. The accepted values are either true or false. Default is true.

      localename
      Optional: The locale to index.

      • All

      • de_DE

      • en_US

      • es_ES

      • fr_FR

      • it_IT

      • ja_JP

      • ko_KR

      • pl_PL

      • pt_BR

      • ro_RO

      • ru_RU

      • zh_CN

      • zh_TW

      Default is All.

      Note: To index a new language, this language should be added in SRCHCONF table and SRCHCONFEXT table. See Indexing a new language in WebSphere Commerce Search

    The response for build index RESTFul call is similar to the following example:

      {"jobStatusId":1001}

    where 1001 is the job id for this build index.

  2. Check build index status.

      https://{ts_server_hostname}:{ts_https_port}/wcs/resources/admin/index/dataImport/status?jobStatusId={jobstatusId}
      Method: GET
      header: basic auth for spiuser and its password
      Response example:
      {
          "status": {
              "finishTime": "2017-11-09 08:03:39.825689",
              "lastUpdate": "2017-11-09 08:03:39.825689",
              "progress": "100%",
              "jobStatusId": "8002",
              "startTime": "2017-11-09 08:02:36.649198",
              "message": "Indexing job started for masterCatalogId:10,001.\r\nIndexing job finished successfully for masterCatalogId:10001.\r\n",
              "jobType": "SearchIndex",
              "properties": "[localeName=en_CA]",
              "status": "0"
          }
      }
      status=0 and progress=100% means build index successfully executed.
      status=-1 and progress!=100% means build index is in progress.
      other status means build index failed, error message can be found in "message" field.
      To get more logging information, enable "com.ibm.commerce.foundation.*=FINEST" in transaction server, enable "com.ibm.commerce.foundation.*=FINEST, com.ibm.commerce.search.*=FINEST" in search server.
      Reply

    We can also check the status using the Linux cURL command.

      curl -k -u spiuser:plain_text_spiuserPassword -X GET https://hostname:3738/search/admin/resources/index/build/status?jobStatusId=jobstatusId


What to do next

After the search index builds, we can optionally replicate and propagate the WebSphere Commerce Search index.