Skip to content

Products

In order to search for products in Ecommerce Search, they first need to be ingested. Ingestion of products is done through the Ecommerce Search API, at /api/ingestion/segments/{segmentId}/products. See the full API reference here.

The Ecommerce Search ingestion API supports multiple sources of data. It is possible to ingest product data from e.g. the PIM, but also provide additional data from a different source. The primary ingestion endpoint is PUT /api/ingestion/segments/{segmentId}/products/bulk.

Endpoint limits

The product and SKU ingestion endpoints have maximum entity sizes, so ingestion must be batched if there are more entities than the limit.

It is also possible to patch products, updating specific properties. The intended use is to enable secondary providers of product information. A typical example might be to have a primary provider create products into Ecommerce Search, but have a secondary provider patch commercial parameters onto existing products. When patching, only non-null values are added to the product. E.g. a request with productNo = null will not overwrite the product number. Note that the products will have to be created before they can be patched. Changes in the data provider, like the PIM, will not be detected automatically by Ecommerce Search, and must be patched again externally.

Deletion is done in bulk at POST /api/ingestion/segments/{segmentId}/products/delete-bulk.

Ingesting SKUs follows the same rules as products, but uses /api/ingestion/segments/{segmentId}/skus instead.

Segmentation

As the endpoint URLs indicate, a set of searchable products exists for each segment. This means that products must be ingested for each segment. Whenever a publication is made for a segment, Ecommerce Search has to build a new index for the segment before it is ready for searching. Depending on the number of products in the segment, this might take some time.

Changes to products or SKUs made through the API are applied immediately. This means that it is possible to affect the search experience without creating a new publication.

Examples

Ingesting products

Given a file with product data, this example shows how to ingest products into Ecommerce Search.

public async Task CreateProducts(string segmentId)
{
    // Load product data from file, for demonstration purposes
    var products = await JsonFileParser.ParseModelAsync<ProductCreateBulkModel[]>("Products.json");
    var client = await searchClientFactory.CreateAuthenticatedClientAsync();
    try
    {
        var productBulkRequest = new ProductCreateBulkRequestModel { Products = products };
        await client.CreateProductsAsync(segmentId, productBulkRequest);
    }
    catch (SearchApiException<ProblemDetails> e)
    {
        logger.LogError(e, "Product ingestion failure: {ProblemDetails}", e.Result.Detail);
        throw;
    }
}

SKUs

Ingesting SKUs

Given a file with SKU data this example shows how to ingest SKUs into Ecommerce Search.

private static async Task CreateSkus(ISearchAdministrationClient client, string segmentId)
{
    var skus = await ParseJsonFileToModelAsync<CreateSkuModel[]>("Skus.json");
    var ingestionBatchSize = 1000;

    try
    {
        foreach (var skuBatch in skus.Chunk(ingestionBatchSize))
        {
            var skuBulkRequest = new SkuCreateBulkRequestModel { Skus = skuBatch };
            await client.CreateSkusAsync(segmentId, skuBulkRequest);
        }
    }
    catch (Exception e)
    {
        Console.Write($"Failed creating skus for segment id: {segmentId}, error: {e.Message}");
        throw;
    }

    Console.WriteLine("Created Skus");
}