Tutorials > WebSphere Commerce search
Tutorial: Indexing ratings data in WebSphere Commerce search from an external source
In this tutorial, newly added search fields are used in the Management Center. That is, a Ranking field is added and used as a sorting field when creating search rules. Search rules provide ways to manipulate search result ordering and ranking in starter stores, where the new Ranking field is used as a sort criteria.
Typically, in cases where a predefined field is in the search schema with no data or tables for it in the WebSphere Commerce relational database, the preprocessor provides support. That is, when to index the data for those fields from external sources. The indexing process is broken down into two separate steps. The first is the flattening of the relational tables and the second is the actual indexing of the flattened data using the Data Import Handler (DIH). This two step process also provides a customization midpoint to bring external data into the index. The approach is, using the preprocess configuration extensions, create temporary tables that become part of the other tables that are used during the full index build. In the preprocessor configuration extension, you provide Java extension classes that are called as a final step of the preprocessing. This not only creates the temporary tables needed for the data, but also enables you to insert data into the the temporary tables. That is, the preprocessing creates the new temporary tables and the Java extension class parses the external data and inserts the required data into the temporary tables.
Once the temporary tables are populated with the external data, you can add them as part of the index building step. This is achieved by configuring the DIH configuration file to modify the select queries to include the new temporary tables and provide mapping between the temporary table column and the index field. This ensures that the next time the index build is run, it associates the new table data with the existing data and sends them to the index.
After the external data is indexed, by modifying the Management Center object definition files, it enables you to use the newly added column. In this tutorial, the newly added field can be used as a new sorting filter.
To show the search results in the Madisons starter store, the mediator configuration file is modified accordingly. When a search query is submitted, it is forwarded to the index and then all the results are returned back as XML. In WebSphere Commerce search, the mediation layer handles how the results are manipulated and populated into the logical nouns for other services such as the user interface to consume. This is done in the mediator configuration file. The logical name mapping to the noun fields is provided so that the WebSphere Commerce runtime can automatically populate the fields. Since ranking fields are new and they do not have a placeholder in the CatalogNavigationViewType noun, they are mapped into the user data field. Once the mapping is complete, they are simply extracted and displayed in the Madisons starter store.
The following diagram illustrates this process:
All extensions in this tutorial use an X_ prefix as a recommended customization naming convention.
Learning objectives
After completing this tutorial, you should be able to:
- Understand and customize WebSphere Commerce search
- Understand and customize the preprocessing and indexing process
Time required
Expect this tutorial to take about 2 hours to complete.
Skill level
Advanced
Audience
This tutorial is intended for WebSphere Commerce developers responsible for creating and customizing WebSphere Commerce BOD services.
System requirements
Before beginning this tutorial ensure that you have:
- Installed WebSphere Commerce v7
- Installed Feature Pack 2
- Installed WebSphere Commerce Developer v7
Prerequisites
Ensure you have completed the following prerequisites:
Workspaces are not supported when completing this tutorial.
To complete this tutorial you should be familiar with the following terms and concepts:
- WebSphere Commerce search
- Web services
- XML
- WebSphere Commerce services
- Relational databases
- SQL
Lessons in this tutorial
- Review the search schema
In this lesson, the search schema is reviewed before continuing on with customizing WebSphere Commerce search. In this tutorial, the customer ranking field is used to index user ratings input as XML data from an external data source.
- Configure the search preprocessor
In this lesson, the preprocessor configuration files are modified for custom data. The preprocessing tasks are controlled by the wc-dataimport-preprocess XML files The configuration file has two main portions: The first is the Java extension class called during the preprocess, and the second is the SQL portion that is used in the Java extension classes to create the temporary tables.
- Preprocessing the search index data
In this lesson, the search index data is preprocessed to prepare the WebSphere Commerce data for indexing. The preprocess utility extracts and flattens WebSphere Commerce data and then outputs the data into a set of temporary tables inside the WebSphere Commerce database. The data in the temporary tables is then used by the index building utility in the next lesson to populate the data into Solr indexes using Solr's Data Import Handler (DIH).
- Configure the Data Import Handler mapping
In this lesson, after the fields are defined in the search schema, the data extraction must be performed from the relational table. The data extraction is handled by the Data Import Handler, containing configuration files with predefined SQL query lines that extract WebSphere Commerce data.To extend the extraction scope, the lesson steps append these queries with the columns and tables for ratings.
- Accept the search index
In this lesson, the full index build is ready to run, since the fields and the extraction mappings have been completed.
- Customize the Business Object Mediator to include custom data
In this lesson, the Business Object Mediator is modified to map the new columns to the user data field of the CatalogEntryView noun. As a result, the search results in the Madisons starter store include the newly added external ratings data.
- Customize the Management Center to use the new indexed column
In this lesson, the Management Center is modified to include Ranking as a sort criteria in the Order Search Result action.
- Modify the Madisons starter store to display the ratings information
In this lesson, the Madisons starter store is customized to display the warranty information with their associated catalog entries.
- Modify the Madisons starter store to display the warranty information
In this lesson, the Madisons starter store is customized to display the warranty information with their associated catalog entries. That is, since the mapping is complete, they are simply extracted and displayed in the Madisons starter store.
- Modify the Madisons starter store to display the ratings information
In this lesson, the Madisons starter store is customized to display the warranty information with their associated catalog entries.
- Add the new search profile
In this lesson, the search query is customized so that it will not only search on the default predefined search fields, but also on one or more of the new fields defined for warranty. This is achieved by extending the wc-search.xml file to include a new search profile definition that extends one of the existing profiles.
- Customize the Management Center to use the new indexed column
In this lesson, the Management Center is modified to include Ranking as a sort criteria in the Order Search Result action.
- Configure the search preprocessor
In this lesson, the preprocessor configuration files are modified for custom data. The preprocessing tasks are controlled by the wc-dataimport-preprocess XML files The configuration file has two main portions: The first is the Java extension class called during the preprocess, and the second is the SQL portion that is used in the Java extension classes to create the temporary tables.
- Preprocessing the search index data
In this lesson, the search index data is preprocessed to prepare the WebSphere Commerce data for indexing. The preprocess utility extracts and flattens WebSphere Commerce data and then outputs the data into a set of temporary tables inside the WebSphere Commerce database. The data in the temporary tables is then used by the index building utility in the next lesson to populate the data into Solr indexes using Solr's Data Import Handler (DIH).
- Review the search schema
In this lesson, the search schema is reviewed before continuing on with customizing WebSphere Commerce search. In this tutorial, the customer ranking field is used to index user ratings input as XML data from an external data source.
Related concepts
Related reference
WebSphere Commerce search tutorials