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>
</lst>
<arr name=”last-components”>
<str>wc_spellcheck</str>
</arr>
</requestHandler>
<!-- content removed for clarity -->
</config>
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"?>
<update>
<add>
<doc>
<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="fullImage">images/catalog/apparel/apparel_160x160/IMG_0054_e.jpg</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="thumbnail">images/catalog/apparel/apparel_70x70/IMG_0054_e.jpg</field>
<field name="xquantity">30</field>
</doc>
<!-- you can have multiple <doc> ... </doc> in one add element -->
</add>
<!-- inside the update element you can have add’s and delete’s
<delete>
<id>10245</id>
</delete>
</update>
2. HTTP/POST the inventory_update_message.xml to the search server using post.sh
(see Example 7-10):
redbooks@linux-8sjm:~>./post.sh inventory_update_message.xml
Example 7-10 post.sh
#!/usr/bin/sh
# 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
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
FILES=$*
URL=http://linux-8sjm.site:3737/solr/MC_10001_CatalogEntry_en_US/update
echo $URL
for f in $FILES; do
echo Posting file $f to $URL
curl $URL --data-binary @$f -H 'Content-type:application/xml'
echo
done
#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.