APIs for Customer Search

You can use the search relevance functionality to improved performance.

Many customers use the Salesforce B2C Commerce scripting API to run customer searches. B2C Commerce automatically performs a full-text search.

Note: To take advantage of the search relevance functionality and its improved performance, convert all code to use the searchProfiles and processProfiles methods.

API Usage

The dw.customer.CustomerMgr APIs behave as follows:

  • Wildcards are filtered from the query (*, %, +) and replaced by spaces.
  • LIKE and ILIKE queries are executed as full text queries (working on whole words).
  • LIKE queries are case insensitive.
  • Using logical operators can change the execution of LIKE/ILIKE clauses to exact string comparisons, depending on how they are combined.

    LIKE and ILIKE work on the entire text, but with some text preprocessing, such as stemming. This type of analysis, however, can't be used on some queries, depending on the combination of logical operators.

  • Using logical operators can result in degraded performance, depending on how they are combined.

    Having both AND and OR in the same query impacts performance.

  • Having range queries (which includes anything such as a>b) impacts performance.

  • The search only returns the first 1000 hits from the search result.

Customer Profile Batch Processing API

The scripting API, dw.customer.CustomerMgr.processProfiles() enables you to process customer profiles in batch mode. This API, based on the full text search service, can process a many profile objects with optimized search performance and memory management.

Use this API in custom jobs to replace these older APIs:

  • dw.customer.CustomerMgr.queryProfiles(…)
  • dw.object.SystemObjectMgr.querySystemObject(profile, …)

The dw.customer.CustomerMgr.processProfiles(…) API accepts a customer profile object query and a JavaScript callback function as input parameters. The method searches customer profiles based on the specified query parameters and executes the specified callback function for each search result.

Here is an example of how you would use this API:

function callback(profile: Profile)
{
 // PROCESSING CODE GOES HERE 
}
 dw. customer.CustomerMgr.processProfiles("gender=1", callback);