Chapter 7. Index design and data load 197
<!-- Filter all queries to ensure returned catalog entries have quantity -->
<lst name=”appends”>
<str name=”fq”>xquantity:[1 TO *]</str>
<arr name=”last-components”>
<!-- content removed for clarity -->
7.3.2 Index maintenance
Automatic re-indexing is an event-driven process in WebSphere Commerce V7.0. When a
message is received to mutate the base schema, ChangeCatalogEntry events are raised and
handled by WebSphere Commerce V7.0. These handlers parse the event and mutate
TI_DELTA_CATENTRY. Then, when a CategoryNavigationView message is received, it raises
a SynchronizeIndexEvent if the table is not empty. Neither case raises a ChangeCatalogEntry
event; therefore the TI_DELTA_CATENTRY table is not mutated and we must use the
following re-indexing strategies.
The maintenance for our customized index introduces two separate index update cases:
򐂰 The inventory update feed is received and loaded into the WebSphere Commerce V7.0
database. We run a full re-index after each inventory feed load to handle this case.
򐂰 An inventory update is caused by a storefront order. We set up a scheduled job,
RBInventoryDeltaUpdateIndexCmd, which is a sample exercise, that generates an XML
message for all catalog entries that have INVENTORY.QUANTITY = 0. Then, we
HTTP/POST the message to the WebSphere Commerce V7.0 search server.
Follow these steps:
1. Schedule RBInventoryDeltaIndexCmd to run at a certain frequency, f1, that will generate
an inventory_update_message.xml (see Example 7-9).
Example 7-9 inventory_update_message.xml
<?xml version="1.0" encoding="UTF-8"?>
<field name="buyable">1</field>
<field name="catalog_id">10001</field>
<field name="catentry_id">10246</field>
<field name="catenttype_id_ntk_cs">ProductBean</field>
<field name="member_id">7000000000000000002</field>
<field name="mfName">MapleWear</field>
<field name="mfName_ntk">MapleWear</field>
<field name="mfName_ntk_cs">MapleWear</field>
<field name="name">Bodysuit</field>
<field name="parentCatgroup_id_facet">10001_10031</field>
<!-- handle arrays by flattening and repeating the field name element -->
198 WebSphere Commerce V7.0 Feature Pack 2 Search Solution Overview and Deployment
<field name="parentCatgroup_id_search">10001_10031</field>
<field name="parentCatgroup_id_search">10001_10029</field>
<field name="partNumber_ntk">MW-0054</field>
<field name="price_USD">6.99</field>
<field name="published">1</field>
<field name="shortDescription">Short-sleeved bodysuit.</field>
<field name="storeent_id">10001</field>
<field name="xquantity">30</field>
<!-- you can have multiple <doc> ... </doc> in one add element -->
<!-- inside the update element you can have add’s and delete’s
2. HTTP/POST the inventory_update_message.xml to the search server using
(see Example 7-10):
redbooks@linux-8sjm:~>./ inventory_update_message.xml
Example 7-10
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# See the License for the specific language governing permissions and
# limitations under the License.
echo $URL
for f in $FILES; do
echo Posting file $f to $URL
curl $URL --data-binary @$f -H 'Content-type:application/xml'
#send the commit command to make sure all the changes are flushed and visible
curl $URL --data-binary '<commit/>' -H 'Content-type:application/xml'
echo "complete"

Get WebSphere Commerce V7.0 Feature Pack 2 Search Solution Overview and Deployment now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.