Push data to Coveo (SAP Commerce Cloud 2205 or later)
Push data to Coveo (SAP Commerce Cloud 2205 or later)
This article explains how to push data from an SAP Commerce Cloud (version 2205 or later) to a Coveo organization.
Prerequisites
You’ll need the Coveo Push API client library for Java, so make sure that:
-
Your project meets the prerequisites specified in the library’s installation guide.
-
Apache Maven is installed on your machine.
Install the Coveo indexer push extension
The Coveo Search Provider SAP Commerce Extension allows your SAP project to exchange data with Coveo. To install the extension, perform the following steps:
-
Copy the extension repository to the
hybris/bin/custom
directory of your project. -
Open the
hybris/config/localextensions.xml
file and add thesearchprovidercoveosearchservices
extension:<extension name='searchprovidercoveosearchservices' />
-
Install the Coveo Push API client library for Java:
-
Open the Apache Maven
settings.xml
file. The file is located at${user.home}/.m2/settings.xml
. -
Add a repository definition for the library’s GitHub Package.
<repository> <id>github</id> <url>https://maven.pkg.github.com/coveo/push-api-client.java</url> <snapshots> <enabled>true</enabled> </snapshots> </repository>
-
Specify your GitHub personal access token (classic) to be able to install packages from GitHub Packages.
The token should have at least
read:packages
permission.<servers> <server> <id>github</id> <username>USERNAME</username> <password>TOKEN</password> </server> </servers>
-
-
Set up the Ant environment by running the script:
. ./setantenv.sh
-
From the root of your project directory, run the following command:
ant clean all
-
After the command execution, navigate to the
hybris/bin/platform
directory. -
Start your SAP Commerce installation by running the script:
./hybrisserver.sh
By default, your local server would use ports 9001 (http) and 9002 (https).
-
Open the Hybris Administration console at https://localhost:9002/platform/update. You can also navigate to the Update page by clicking Platform → Update in the top menu.
-
Find and select the checkboxes for:
-
searchprovidercoveosearchservices
(required to create the new search provider) -
Update running system
-
Localize types
-
-
At the top of the page, click Update.
Note
The extension creates new data types in the database, but it doesn’t import any data. |
Semi-automatic configuration
In the extension code base, if you navigate to You can also manually configure every source and your indexes via the Backoffice. Perform the following steps to do so. |
Coveo setup
Step 1: Create a source in your Coveo organization
For storing the SAP catalog data, you need a Catalog source.
-
Log in to the Coveo Administration Console.
-
Create the Catalog sources that you’ll be pushing your data to.
The guidelines for creating sources are:
-
Each combination of language, currency, and country existing in your data should have a separate Coveo Catalog source to push to.
-
Any availability data you have should also have it’s own dedicated Catalog source.
-
-
Take note of the Stream API URL value for your source.
Step 2: Create an API key
Create one API key that you’ll use for all your sources. See Manage API Keys.
The key should have the edit privileges detailed here: Catalog source privileges. See the Edit sources, edit source update schedules, and view the View Metadata page row in the privileges table.
SAP Commerce setup
Step 1: Create Coveo sources
For each source you created in the Coveo Administration Console you should perform the following steps in the SAP Backoffice.
-
In the SAP Backoffice Administration Cockpit, go to System → API → Destinations → Coveo Source.
-
Click the plus sign (+) above the search results.
-
In the modal window that appears, enter a unique ID that represents your Catalog source. It’s recommended to use a human-readable value to assist with identifying a specific source.
-
Click Finish.
-
Select the newly created item from the search listing.
-
On the General tab:
-
Fill in the Name field.
-
In the Object type menu, specify the type that matches your Coveo source:
AVAILABILITY
This type is for the availability source. See Source configuration approaches for availability channel and Catalog availability data.
PRODUCTANDVARIANT
This type is for the the products and variations of the catalog. See Catalog product data and Catalog variant data and product groupings.
When selecting an object type of PRODUCTANDVARIANT, Language, Currency, and Country are mandatory for the system to determine the correct source for your product data.
-
-
Click Save.
Step 2: Create a consumed destination
-
Go to System → API → Destinations → Consumed Destinations.
-
Click the plus sign (+) above the search results.
-
In the modal window that appears:
ID
Enter a unique ID that represents your Catalog source.
URL
Paste the Stream API URL that you copied from the Coveo Catalog source.
Details
-
In your Coveo organization, open the Catalog source you created in step 2.
-
On the Configuration tab, there’s a section called Stream API URL. Click Copy to clipboard to copy the URL.
Active
Verify that the Active checkbox is selected.
Destination Target
Click the field and select Default_Template.
NoteThe destination target you select doesn’t matter as it’s not used in the push implementation and only needed to create the destination.
-
-
Click Finish.
Now you see the destination you created in the list of consumed destinations.
Step 3: Create a credential for the consumed destination
If you have a number of sources, you only need to create one OAuth Credential and attach it to many Consumed Destinations. |
-
Click the destination you created and switch to the Destination Configuration tab.
-
Double-click in the Credential field to open a dropdown menu and select Create Credential → Consumed OAuth Credential.
-
Fill in the following fields:
ID
Enter a unique ID for a new credential. For example,
CoveoCredential
.Client ID
Enter a client ID for a new credential. For example,
CoveoClientID
. -
Click Finish. You see the Destination Configuration tab again.
-
Double-click in the Credential field to open the credential settings.
-
In the Client Secret section, there are Password and Verify password fields. In both fields, paste the Coveo API key that you created earlier.
-
Click Save to save and close the credential settings.
-
Click Save to save the destination settings.
Step 4: Assign the consumed destination to the Coveo source
-
Return to System → API → Destinations → Coveo Source.
-
Click your Coveo source.
-
On the General tab, find the Consumed Destination field.
-
Specify the consumed destination that you created earlier.
-
Click Save.
Step 5: Create a search provider
Now that you’ve mapped the Coveo sources to the SAP Commerce API destinations, you need to configure the search index to push the data to Coveo.
-
Go to the System → Search and Navigation → Search Provider Configurations page.
-
Next to the plus sign, click the dropdown menu and select Coveo Search Provider Configuration.
-
Fill in the following fields:
Identifier
Enter a unique identifier for a new search provider, for example,
CoveoSearchProviderID
.Name
Enter a name for a new search provider, for example,
Coveo Search Provider Configuration
.Coveo Source
Select all the Coveo sources that you created.
-
Click Finish. Now you see the provider you created in the list of search providers.
Step 6: Create the index configuration
-
Go to System → Search and Navigation → Index Configurations.
-
Next to the plus sign (+), click the dropdown menu and select CoveoSnIndexConfiguration.
-
Fill in the following fields:
Identifier
Enter a unique identifier for a new configuration, for example,
CoveoIndexID
.Name
Enter a name for a new search provider, for example,
Coveo Index Configuration
.Search Provider Configuration
Select the Coveo Search Provider Configuration created in the previous step.
-
Click Next to proceed to the next step, Index Types.
Skip this step for now and click Next again.
-
In the Session step, select all the Languages, Currencies, and Countries that are relevant for your data.
-
Click Finish.
Step 7: Create the ServiceLayerJobs
Create the ServiceLayerJobs for the future cron jobs, one for full indexing and one for incremental indexing.
-
Go to System → Types.
-
In the search bar, type in
ServicelayerJob
and search. -
In the search results, click the ServicelayerJob.
The properties of the ServicelayerJob are displayed on the page.
-
In the upper part of the properties, click the search icon that’s titled Search by type.
-
Click the plus sign (+) above the search listing.
-
In the modal window that appears:
Spring ID
Paste
fullCoveoSnIndexerJob
.Code
Paste
fullCoveoSnIndexerJob
. -
Click Finish.
-
Perform the same steps to create another ServicelayerJob for which specify
incrementalCoveoSnIndexerJob
for the Code and the Spring ID attributes.
Step 8: Create the Index types
Create one Index type for full indexing and one for incremental indexing.
-
Go to System → Search and Navigation → Index Types.
-
Click the plus sign (+) above the search results.
-
In the modal window that appears, in the Essential step, fill in the following fields:
Identifier
Enter a unique identifier for a new type, for example,
CoveoFullIndexTypeID
.Name
Enter a name for a new type, for example,
Coveo Full Index Type Configuration
.Composed Type
Specify the type that matches a Coveo Object type for the source you’ll use this to push data to.
ExampleIf this index type will be used to push
availability
objects, then you may want to select theWarehouse
Composed type. This will be dependent on how your data is structured.Index Configuration
Select the Coveo Index Configuration created in the previous steps.
-
The next steps can be configured later, so you may skip them for now. Click Next to proceed to the Cron Jobs step.
-
In the Cron Jobs step, click the plus sign (+) at the end of the dropdown menu.
-
Select Full Indexer Cronjob.
-
Fill in the following fields:
-
Code. Enter a unique code for the cron job, for example,
coveoFullIndexType
. -
Job Definition. Select the
fullCoveoSnIndexerJob
system type. The chosen type should correspond to the type of cron job you’re creating. -
Indexer Item Source. Click this field to create a Flexible Search Indexer Item Source.
In the modal window that appears, fill in the Query field. It must be the FlexibleSearch query that will be used to retrieve the Composed Type. For example, if you selected Warehouse for your
availability
object, the following query would retrieve all warehouses for the electronics site:`SELECT {w:PK} FROM {Warehouse as w JOIN BaseStore2WarehouseRel as rel ON {w:PK} = {rel:target} JOIN BaseStore AS bs ON {rel:source} = {bs:PK} } WHERE {bs:uid}='electronics'`
For product indexing, the following query would retrieve all approved products in the catalog.
`SELECT {p:pk} FROM {Product AS p LEFT JOIN ArticleApprovalStatus AS a ON {p:approvalStatus} = {a:pk}} WHERE {a:code} = 'approved'`
-
-
Click Finish for every modal window that has been opened.
-
Select the newly created Index type.
-
On the General tab, configure the Identity Provider as
snIdentityProvider
and link the catalog you want to index in the Catalogs field. -
Perform the same steps to create an Index type for incremental indexing, but adjust them as follows:
-
in the Essential step, update the Identifier and Name fields to reflect the incremental indexing type.
-
in the Create Cron Jobs step, select Incremental Indexer Cronjob. Use
coveoIncrementalIndexType
for the Code attribute andincrementalCoveoSnIndexerJob
for the Job Definition attribute. Update the FlexibleSearch query to match the incremental indexing requirements.
-
Step 9: Create the objectType field
In both created Index types, create a field that will be used to specify the Coveo object type.
-
Click the required Index type, either
coveoFullIndexType
orcoveoIncrementalIndexType
. -
Switch to the Fields tab.
-
For Coveo Push solution, the Code, Name, and DocumentId fields are mandatory.
-
Click in the Fields menu, to create a field specific for Coveo.
NoteYou can create as many additional fields as you need to push to Coveo. In this example, you’ll create one field,
objectType
. -
In the modal window that appears, fill in the following fields:
Identifier
Enter
objectType
.Name
Enter
Object Type
.Field Type
Select
TEXT
. -
Click Next.
-
In the Indexer step, paste
coveoObjectTypeSnIndexerValueProvider
in the Value Provider field. -
Click Finish.
-
In your SAP Commerce Cloud project, open the
hybris/bin/custom/searchprovidercoveosearchservices/project.properties
file. -
There will be three properties, each maps one Coveo Source object with one or more Composed Index types.
For example, if you created a
Warehouse
Composed index type for theavailability
object, add it to thecoveo.availability.typecodes
property.coveo.availability.typecodes=Warehouse coveo.product.typecodes=Product coveo.variant.typecodes=VariantProduct
Step 10: Map the catalog fields
For both created Index types, map catalog fields with the Coveo fields. Do the mapping only for the fields that you want to push to Coveo.
-
Navigate to the System → Search and Navigation → Index Types page.
-
In the list of index types, click the required index type.
-
Switch to the Fields tab.
-
Examine the Identifier column. The values in it should match the field name that was set within the source in the Coveo Administration Console.
ExampleFor the SAP field
name
, you need to create the mapping%[name]
in the Coveo Administration Console.←→
-
If you need to create a new field, do so the same way you created the
objectType
field in the previous step.
Step 11: Run the indexers
Once you’ve configured your system correctly, you can run your indexers.
-
Navigate to the System → Search and Navigation → Index Types page.
-
In the list of index types, click the required index type.
-
Switch to the Cron Jobs tab.
-
Click the required cronjob.
-
Make sure that the cronjob is enabled, see the True checkbox in the Enabled section.
-
Click Save to save and close the cronjob settings.
-
While having the index type open, switch to the Administration tab.
-
Check that the Stores field is set to the store you want to index.
-
Above the index tabs, click Run indexer.
-
In the modal window that appears, click the dropdown menu and select the cronjob that you’ve just enabled.
-
Click Run.
You can track the indexing progress by clicking Processes at the top of the Administration Cockpit.