Creating a new search expression

Search expressions performed by WebSphere Commerce services use an expression language known as XML Path Language, or, more commonly, XPath. If you are new to XPath, you must familiarize yourself with the notation before proceeding with this customization task. WebSphere Commerce has also extended the notation for XPath to allow control over the display and ordering of the results, as well as selection of business logic command implementations.

About this task

To create a new search expression:


  1. Create a new XPath search expression that describes the search you want to perform. For example, if you want to create a service where the customer can search the catalog based on a price range, use the following XPath to perform the query:
    and Price >= '$minPrice$')
    and (Price[@currency='$currency$'] and Price <= '$maxPrice$')
    Note: The XPath expression matches the structure of the logical schema. When searching on custom components, a well-defined logical model makes it simpler to write your XPath expressions.
  2. In your customization project, create a new service command that implements the FetchNounCmd interface. This command performs the search expression. An example of a new service command can be downloaded; see See the Design pattern for Get service implementation for more information.
    Note: For member subsystem customization, one default fetch command does all the interpretation of the XPath for each noun. You must extend this command to create new search expressions. You need to call super.performExecute() in your performExecute(), and then select your data based on your new XPath query. For example:
       public void performExecute() throws Exception {
                    // Member subsystem code example follows
    (additional code may precede this ...) 
                    SelectionCriteriaMapper selectionCriteria = new
                    Map mapQueryParameters =
                    boolean bPersonFound = false;
                    // Check if search expression is our customized
    expression based on LogonID: 
                    if (mapQueryParameters.get("LogonID") != null) {
                            // Add customized code to find Person by
    logon ID ...
                            bPersonFound = true;
                    // if Person was not found, call parent class for
    default expressions
                    if ( !bPersonFound) {
                    //Code example ends -- additional code may follow
  3. Register your new command. When you do so, you need to associate the XPath search expression key with your new custom fetch command implementation with an SQL statement. For example:
    and Price[@currency=]) 
    and (Price>= and Price[@currency=])]]]]',
    1. The interface name contains the name of the command concatenated with the XPath.
    2. For member subsystem customization, you need to update the CMDREG entry for the existing default fetch command. Also, no XPath details are included in the SQL update.
  4. Restart WebSphere Commerce