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 the /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. The ingestion endpoint has a max batch size, so ingestion must be batched if there are more products than this limit. Ingesting data is easily done with the SDK client:

private readonly ISearchAdministrationClientFactory _administrationClientFactory;

{...}

public async Task IngestProducts(string segmentId, IEnumerable<ProductCreateBulkModel> products){
    var client = await _administrationClientFactory.CreateAuthenticatedClientAsync();

    foreach (var productBatch in products.Chunk(1000))
    {
        var productBulkRequest = new ProductCreateBulkRequestModel { Products = productBatch };
        await client.CreateProductsAsync(segmentId, productBulkRequest);
    }
}

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 repatched 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

Products

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

Example

private static async Task CreateProducts(ISearchAdministrationClient client, string segmentId)
{
    var products = await ParseJsonFileToModelAsync<CreateProductModel[]>("Products.json");
    var ingestionBatchSize = 1000;

    try
    {
        foreach (var productBatch in products.Chunk(ingestionBatchSize))
        {
            var productBulkRequest = new ProductCreateBulkRequestModel { Products = productBatch };
            await client.CreateProductsAsync(segmentId, productBulkRequest);
        }
    }
    catch (Exception e)
    {
        Console.Write($"Failed creating products for segment id: {segmentId}, error: {e.Message}");
        throw;
    }

    Console.WriteLine("Created Products");
}
Products.json
[
    {
        "name": "Bizzkit T-Shirt",
        "shortDescription": "For training",
        "longDescription": "",
        "productNumber": "none",
        "rating": 0.0,
        "activeFromUtc": "0001-01-01T00:00:00+00:00",
        "activeToUtc": "9999-12-31T23:59:59.9999999+00:00",
        "alternativeIds": [],
        "alternativeSearchWords": [],
        "categories": [{
                "categoryPathElements": [{
                        "categoryId": "Type",
                        "categoryName": "Bizzkit"
                    }
                ]
            }
        ],
        "media": [],
        "productId": "BZ01"
    }, {
        "name": "BK T-Shirt",
        "shortDescription": "For men",
        "longDescription": "",
        "productNumber": "none",
        "rating": 0.0,
        "activeFromUtc": "0001-01-01T00:00:00+00:00",
        "activeToUtc": "9999-12-31T23:59:59.9999999+00:00",
        "alternativeIds": [],
        "alternativeSearchWords": [],
        "categories": [{
                "categoryPathElements": [{
                        "categoryId": "Type",
                        "categoryName": "Bizzkit"
                    }
                ]
            }
        ],
        "media": [],
        "productId": "BZ02"
    }, {
        "name": "Cart T-shirt",
        "shortDescription": "E-Commerce 4ever",
        "longDescription": "",
        "productNumber": "none",
        "rating": 0.0,
        "activeFromUtc": "0001-01-01T00:00:00+00:00",
        "activeToUtc": "9999-12-31T23:59:59.9999999+00:00",
        "alternativeIds": [],
        "alternativeSearchWords": [],
        "categories": [{
                "categoryPathElements": [{
                        "categoryId": "Type",
                        "categoryName": "Ecommerce"
                    }
                ]
            }
        ],
        "media": [],
        "productId": "BZ03"
    }, {
        "name": "CMS T-Shirt",
        "shortDescription": "For women",
        "longDescription": "",
        "productNumber": "none",
        "rating": 0.0,
        "activeFromUtc": "0001-01-01T00:00:00+00:00",
        "activeToUtc": "9999-12-31T23:59:59.9999999+00:00",
        "alternativeIds": [],
        "alternativeSearchWords": [],
        "categories": [{
                "categoryPathElements": [{
                        "categoryId": "Type",
                        "categoryName": "Bizzkit"
                    }
                ]
            }
        ],
        "media": [{
                "type": "Image",
                "url": "https://docs.academy02.test/OrangeCMS3.c59253dd-f56c-4a3a-b484-f6eac0a7654d.jpg",
                "metadata": ""
            }
        ],
        "productId": "BZ04"
    }, {
        "name": "Commercial Sort T-Shirt",
        "shortDescription": "See ES",
        "longDescription": "",
        "productNumber": "none",
        "rating": 0.0,
        "activeFromUtc": "0001-01-01T00:00:00+00:00",
        "activeToUtc": "9999-12-31T23:59:59.9999999+00:00",
        "alternativeIds": [],
        "alternativeSearchWords": [],
        "categories": [{
                "categoryPathElements": [{
                        "categoryId": "Type",
                        "categoryName": "Bizzkit"
                    }
                ]
            }
        ],
        "media": [],
        "productId": "BZ05"
    }, {
        "name": "DAM T-Shirt",
        "shortDescription": "Colorful ",
        "longDescription": "",
        "productNumber": "none",
        "rating": 0.0,
        "activeFromUtc": "0001-01-01T00:00:00+00:00",
        "activeToUtc": "9999-12-31T23:59:59.9999999+00:00",
        "alternativeIds": [],
        "alternativeSearchWords": [],
        "categories": [{
                "categoryPathElements": [{
                        "categoryId": "Type",
                        "categoryName": "Bizzkit"
                    }
                ]
            }
        ],
        "media": [],
        "productId": "BZ06"
    }, {
        "name": "I Love E-Com T-shirt",
        "shortDescription": "Bizzkit love story",
        "longDescription": "",
        "productNumber": "none",
        "rating": 0.0,
        "activeFromUtc": "0001-01-01T00:00:00+00:00",
        "activeToUtc": "9999-12-31T23:59:59.9999999+00:00",
        "alternativeIds": [],
        "alternativeSearchWords": [],
        "categories": [{
                "categoryPathElements": [{
                        "categoryId": "Type",
                        "categoryName": "Ecommerce"
                    }
                ]
            }
        ],
        "media": [],
        "productId": "BZ07"
    }, {
        "name": "PIM T-Shirt",
        "shortDescription": "To wear on a train",
        "longDescription": "",
        "productNumber": "none",
        "rating": 0.0,
        "activeFromUtc": "0001-01-01T00:00:00+00:00",
        "activeToUtc": "9999-12-31T23:59:59.9999999+00:00",
        "alternativeIds": [],
        "alternativeSearchWords": [],
        "categories": [{
                "categoryPathElements": [{
                        "categoryId": "Type",
                        "categoryName": "Bizzkit"
                    }
                ]
            }
        ],
        "media": [],
        "productId": "BZ08"
    }, {
        "name": "Rating T-Shirt",
        "shortDescription": "5 star product",
        "longDescription": "",
        "productNumber": "none",
        "rating": 0.0,
        "activeFromUtc": "0001-01-01T00:00:00+00:00",
        "activeToUtc": "9999-12-31T23:59:59.9999999+00:00",
        "alternativeIds": [],
        "alternativeSearchWords": [],
        "categories": [{
                "categoryPathElements": [{
                        "categoryId": "Type",
                        "categoryName": "Ecommerce"
                    }
                ]
            }
        ],
        "media": [],
        "productId": "BZ09"
    }, {
        "name": "Rocket T-Shirt",
        "shortDescription": "Bizzkit in space",
        "longDescription": "",
        "productNumber": "none",
        "rating": 0.0,
        "activeFromUtc": "0001-01-01T00:00:00+00:00",
        "activeToUtc": "9999-12-31T23:59:59.9999999+00:00",
        "alternativeIds": [],
        "alternativeSearchWords": [],
        "categories": [{
                "categoryPathElements": [{
                        "categoryId": "Type",
                        "categoryName": "Ecommerce"
                    }
                ]
            }
        ],
        "media": [],
        "productId": "BZ10"
    }, {
        "name": "Search T-Shirt",
        "shortDescription": "For spacemen",
        "longDescription": "",
        "productNumber": "none",
        "rating": 0.0,
        "activeFromUtc": "0001-01-01T00:00:00+00:00",
        "activeToUtc": "9999-12-31T23:59:59.9999999+00:00",
        "alternativeIds": [],
        "alternativeSearchWords": [],
        "categories": [{
                "categoryPathElements": [{
                        "categoryId": "Type",
                        "categoryName": "Bizzkit"
                    }
                ]
            }
        ],
        "media": [],
        "productId": "BZ11"
    }, {
        "name": "Unlimited T-Shirt",
        "shortDescription": "I love E-Commerce",
        "longDescription": "",
        "productNumber": "none",
        "rating": 0.0,
        "activeFromUtc": "0001-01-01T00:00:00+00:00",
        "activeToUtc": "9999-12-31T23:59:59.9999999+00:00",
        "alternativeIds": [],
        "alternativeSearchWords": [],
        "categories": [{
                "categoryPathElements": [{
                        "categoryId": "Type",
                        "categoryName": "Ecommerce"
                    }
                ]
            }
        ],
        "media": [],
        "productId": "BZ12"
}
]

SKUs

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

Example

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");
}
Skus.json
[
    {
        "productId": "BZ01",
        "skuNo": "BZ01",
        "name": "Bizzkit T-Shirt",
        "stringAttributes": {
            "Color": ["Blue"]
        },
        "numberAttributes": {},
        "intervalAttributes": {},
        "stock": 125,
        "prices": {
            "priceGroupPrices": [{
                    "priceGroupId": "default",
                    "price": 1000,
                    "listPrice": 1000
                }
            ]
        },
        "commercialParameters": {
            "click": "2500",
            "weather": "20",
            "contributionmargin": "50",
            "instock": "125",
            "trend": "6",
            "color": "0"
        },
        "skuId": "BZ01"
    }, {
        "productId": "BZ02",
        "skuNo": "BZ02",
        "name": "BK T-Shirt",
        "stringAttributes": {
            "Color": ["Blue"]
        },
        "numberAttributes": {},
        "intervalAttributes": {},
        "stock": 90,
        "prices": {
            "priceGroupPrices": [{
                    "priceGroupId": "default",
                    "price": 800,
                    "listPrice": 800
                }
            ]
        },
        "commercialParameters": {
            "click": "200",
            "weather": "20",
            "contributionmargin": "40",
            "instock": "90",
            "trend": "8",
            "color": "0"
        },
        "skuId": "BZ02"
    }, {
        "productId": "BZ03",
        "skuNo": "BZ03",
        "name": "Cart T-shirt",
        "stringAttributes": {
            "Color": ["Grey"]
        },
        "numberAttributes": {},
        "intervalAttributes": {},
        "stock": 50,
        "prices": {
            "priceGroupPrices": [{
                    "priceGroupId": "default",
                    "price": 1200,
                    "listPrice": 1200
                }
            ]
        },
        "commercialParameters": {
            "click": "3100",
            "weather": "30",
            "contributionmargin": "50",
            "instock": "50",
            "trend": "2",
            "color": "1"
        },
        "skuId": "BZ03"
    }, {
        "productId": "BZ04",
        "skuNo": "BZ04",
        "name": "CMS T-Shirt",
        "stringAttributes": {
            "Color": ["Orange"]
        },
        "numberAttributes": {},
        "intervalAttributes": {},
        "stock": 5,
        "prices": {
            "priceGroupPrices": [{
                    "priceGroupId": "default",
                    "price": 1100,
                    "listPrice": 1100
                }
            ]
        },
        "commercialParameters": {
            "click": "600",
            "weather": "90",
            "contributionmargin": "60",
            "instock": "5",
            "trend": "3",
            "color": "2"
        },
        "skuId": "BZ04"
    }, {
        "productId": "BZ05",
        "skuNo": "BZ05",
        "name": "Commercial Sort T-Shirt",
        "stringAttributes": {
            "Color": ["Orange"]
        },
        "numberAttributes": {},
        "intervalAttributes": {},
        "stock": 50,
        "prices": {
            "priceGroupPrices": [{
                    "priceGroupId": "default",
                    "price": 900,
                    "listPrice": 900
                }
            ]
        },
        "commercialParameters": {
            "click": "3600",
            "weather": "95",
            "contributionmargin": "65",
            "instock": "50",
            "trend": "1",
            "color": "2"
        },
        "skuId": "BZ05"
    }, {
        "productId": "BZ06",
        "skuNo": "BZ06",
        "name": "DAM T-Shirt",
        "stringAttributes": {
            "Color": ["Orange"]
        },
        "numberAttributes": {},
        "intervalAttributes": {},
        "stock": 9,
        "prices": {
            "priceGroupPrices": [{
                    "priceGroupId": "default",
                    "price": 800,
                    "listPrice": 800
                }
            ]
        },
        "commercialParameters": {
            "click": "610",
            "weather": "45",
            "contributionmargin": "60",
            "instock": "9",
            "trend": "9",
            "color": "2"
        },
        "skuId": "BZ06"
    }, {
        "productId": "BZ07",
        "skuNo": "BZ07",
        "name": "I Love E-Com T-shirt",
        "stringAttributes": {
            "Color": ["Grey"]
        },
        "numberAttributes": {},
        "intervalAttributes": {},
        "stock": 300,
        "prices": {
            "priceGroupPrices": [{
                    "priceGroupId": "default",
                    "price": 800,
                    "listPrice": 800
                }
            ]
        },
        "commercialParameters": {
            "click": "3300",
            "weather": "80",
            "contributionmargin": "50",
            "instock": "300",
            "trend": "8",
            "color": "1"
        },
        "skuId": "BZ07"
    }, {
        "productId": "BZ08",
        "skuNo": "BZ08",
        "name": "PIM T-Shirt",
        "stringAttributes": {
            "Color": ["Orange"]
        },
        "numberAttributes": {},
        "intervalAttributes": {},
        "stock": 250,
        "prices": {
            "priceGroupPrices": [{
                    "priceGroupId": "default",
                    "price": 1000,
                    "listPrice": 1000
                }
            ]
        },
        "commercialParameters": {
            "click": "650",
            "weather": "30",
            "contributionmargin": "60",
            "instock": "250",
            "trend": "2",
            "color": "2"
        },
        "skuId": "BZ08"
    }, {
        "productId": "BZ09",
        "skuNo": "BZ09",
        "name": "Rating T-Shirt",
        "stringAttributes": {
            "Color": ["Grey"]
        },
        "numberAttributes": {},
        "intervalAttributes": {},
        "stock": 110,
        "prices": {
            "priceGroupPrices": [{
                    "priceGroupId": "default",
                    "price": 1300,
                    "listPrice": 1300
                }
            ]
        },
        "commercialParameters": {
            "click": "3200",
            "weather": "65",
            "contributionmargin": "44",
            "instock": "110",
            "trend": "3",
            "color": "1"
        },
        "skuId": "BZ09"
    }, {
        "productId": "BZ10",
        "skuNo": "BZ10",
        "name": "Rocket T-Shirt",
        "stringAttributes": {
            "Color": ["Blue"]
        },
        "numberAttributes": {},
        "intervalAttributes": {},
        "stock": 10,
        "prices": {
            "priceGroupPrices": [{
                    "priceGroupId": "default",
                    "price": 700,
                    "listPrice": 700
                }
            ]
        },
        "commercialParameters": {
            "click": "2400",
            "weather": "50",
            "contributionmargin": "45",
            "instock": "10",
            "trend": "2",
            "color": "0"
        },
        "skuId": "BZ10"
    }, {
        "productId": "BZ11",
        "skuNo": "BZ11",
        "name": "Search T-Shirt",
        "stringAttributes": {
            "Color": ["Grey"]
        },
        "numberAttributes": {},
        "intervalAttributes": {},
        "stock": 800,
        "prices": {
            "priceGroupPrices": [{
                    "priceGroupId": "default",
                    "price": 900,
                    "listPrice": 900
                }
            ]
        },
        "commercialParameters": {
            "click": "3150",
            "weather": "10",
            "contributionmargin": "30",
            "instock": "800",
            "trend": "5",
            "color": "1"
        },
        "skuId": "BZ11"
    }, {
        "productId": "BZ12",
        "skuNo": "BZ12",
        "name": "Unlimited T-Shirt",
        "stringAttributes": {
            "Color": ["Blue"]
        },
        "numberAttributes": {},
        "intervalAttributes": {},
        "stock": 90,
        "prices": {
            "priceGroupPrices": [{
                    "priceGroupId": "default",
                    "price": 500,
                    "listPrice": 500
                }
            ]
        },
        "commercialParameters": {
            "click": "2200",
            "weather": "85",
            "contributionmargin": "80",
            "instock": "90",
            "trend": "4",
            "color": "0"
        },
        "skuId": "BZ12"
    }
]