Developing with ECS Material
This material is for the Developing with ECS course. Please ensure you have attended the Using ECS course and/or read the ECS Concept Article and the Developer Overview Article.
SDK
ECS offers two types of packages: NPM (TypeScript) and NuGet (.NET). The NuGet packages are automated Swagger clients that include a factory client for easy authentication. The NPM packages contain a TypeScript client for the Search Host API.
C#: Getting started
You can easily start with the NuGet packages by using the Getting-Started Console Application. It contains example code on how to create clients.
Try It Yourself
Ensure you have a working C# application.
TypeScript: Getting started
To begin using the TypeScript client, you need the NPM package @bizzkit/ecommerce-search
- see more about the package here. To try out the TypeScript client, you can set up a simple Vite project.
- Add .npmrc to root
- Add package.json to root and packages
- add vite.config.js to root
- add tsconfig.json to root
- add index.ts to root/src
- add index.html to root
- Run and check browser console
Try It Yourself
Ensure you have a working TS/JS application.
Academy playground
We have a created a simple playground for the SearchHost API - contact your instructor for access.
Swagger
You can use the Swagger UI on all APIs to test endpoints.
APIs
As outlined in the Developer Overview Article, ECS offers three APIs.
Admin API
The Admin API manages various aspects of Ecommerce Search. It handles everything from curating dictionaries and parameters to managing products and SKUs. This API equips you with the necessary tools to configure and maintain your search system, ensuring it meets your specific requirements.
Info
Note that the APIs are available in preview versions, which may include endpoints that do not adhere to Bizzkit's release policy and might change between versions.
Most endpoints, such as those related to contexts, dictionaries, facets, parameters, etc., are self-explanatory. Please refer to the Swagger and ECS Documentation.
Try It Yourself
Experiment with some of the endpoints using Swagger or C#. - Get all sections - Add a synonym - Etc.
However, some endpoints require additional information:
Ingestion
To search for a product in ECS, you need to add data, keeping in mind that:
- A searchable product must contain at least one SKU.
- Products comprise various fields - please review Products.
- A SKU is a specific variant of a product and inherits fields from its product/master. Refer to SKUs.
- Products and SKUs can be ingested through:
/api/ingestion/segments/segmentId/products/bulk
/api/ingestion/segments/segmentId/skus/bulk
Here are examples to understand the data that can be ingested into Search. If you'd like to try them, start by creating a new segment and then use Swagger. Trigger all jobs in the job runner to ensure Search is ready to receive data.
Example of 'real' products/SKUs
This a simple example of a "real" product for test/debug, and the summary table (some columns missing):
ProductId | Name | AlternativeIds | AlternativeSearchWords | ShortDescription | Categories |
---|---|---|---|---|---|
bizzkit-beanie-gray-v2 | Bizzkit Beanie Gray | bizzkit-beanie-gray, 123, abc | WinterBeanie, Comfort, Unisex, Cozy, Elegant | Nice beanie for when the... | Clothing, Outerwear, Hats |
This is a simple example of "real" SKUs for test/debug, and the summary table (some columns missing):
SkuId | Name | ProductId | StringAttribute | NumberAttributes | IntervalAttributes | Prices | |||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
bizzkit-beanie-gray-l-v2 | Bizzkit Beanie Gray | bizzkit-beanie-gray-v2 |
|
|
|
|
|||||||
bizzkit-beanie-gray-m-v2 | Bizzkit Beanie Gray | bizzkit-beanie-gray-v2 |
|
|
|
|
Example of 'mock' products/SKUs
This is a simple example of a "mock" products for test/debug (use the /api/ingestion/segments/{segmentId}/products/bulk
endpoint for this purpose), and the summary table (some columns missing):
ProductId | Name | AlternativeIds | AlternativeSearchWords | ShortDescription | Categories |
---|---|---|---|---|---|
product-1 | Product 1 | product-1-extra, 123 | product-1-alternative-1, product-1-alternative-2 | Lorem ipsum dolor sit amet,... | Category 0, Category 1, Category 2 |
product-2 | Product 2 | product-2-extra, 456 | product-2-alternative-1, product-2-alternative-2 | Etiam porta sem malesuada magna... | Category 0, Category 1, Category 3 |
product-3 | Product 3 | product-3-extra, 789 | product-3-alternative-1, product-3-alternative-2 | Curabitur blandit tempus porttitor consectetur... | Category 0, Category 4 |
This is a simple example of a "mock" SKUs for test/debug (use the /api/ingestion/segments/{segmentId}/skus/bulk
endpoint for this purpose), and the summary table (some columns missing):
SkuId | Name | ProductId | StringAttribute | NumberAttributes | IntervalAttributes | Prices | |||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
product-1-sku-1 | SKU 1 for Product 1 | product-1 |
|
|
|
|
|||||||||
product-1-sku-2 | SKU 2 for Product 1 | product-1 |
|
|
|
|
|||||||||
product-2-sku-1 | SKU 1 for Product 2 | product-2 |
|
|
|
|
|||||||||
product-2-sku-2 | SKU 2 for Product 2 | product-2 |
|
|
|
|
|||||||||
product-2-sku-3 | SKU 3 for Product 2 | product-2 |
|
|
|
|
|||||||||
product-3-sku-1 | SKU 1 for Product 3 | product-3 |
|
|
|
|
Example of 'mock' parameters
Demo data for 'mock' parameters
This the 'mock' parameters used. There is not a bulk endpoint so you have to go one parameter a time. You can use the /api/ingestion/segments/{segmentId}/parameters/bulk
endpoint for this purpose.
Data shown as a table:
ParameterId | Name | ParameterType |
---|---|---|
cparameter1 | cparameter1 | Rank |
cparameter2 | cparameter2 | Rank |
Example of 'mock' user affinities
Demo data for 'mock' user affinities
If you would like to experiment with user affinities, here is some template data. You can use the /api/ingestion/segments/{segmentId}/user-affinities/bulk
endpoint for this purpose. Please note that this endpoint might only be available in the preview API.
Data shown as a table:
UserId | Affinities | ||
---|---|---|---|
User1 |
|
||
User2 |
|
||
User3 |
|
Try It Yourself
- Create a new segment (perhaps with a naming convention like
{initials}_mysegment
). - Inject the "mock" products and SKUs.
- Run the job runners (simply select and trigger all jobs).
- Open the UI and view contexts, fields, etc.
Search Host
Searches are conducted through the Search Host API, and it's recommended that all search requests are directed at the UnifiedSearch endpoint.
Request model
Below is a summary table of the Request Model used for searching:
Name | Type | Description |
---|---|---|
segmentId |
string | The segment to search in. An id must have a maximal length of 255 characters, can include only digits, English lowercase and uppercase letters and these characters: -_ |
scopeId |
string | A scope defines a configuration that is applied to the search request. Scopes define the fields that can be returned and the fields that can be filtered on. An id must have a maximal length of 255 characters, can include only digits, English lowercase and uppercase letters and these characters: -_ |
filters |
object | Field name and filter models |
authenticationToken |
string | JWT Token for authenticated search. |
phrase |
string | The phrase to search for |
offsetProducts |
integer | The number of products to skip. |
numberOfProducts |
integer | Indicates the number of records to be fetched. For example, if set to 3, then up to 3 products are returned. Default value is defined on the scope. |
offsetContent |
integer | The number of content to skip. |
numberOfContent |
integer | Indicates the number of records to be fetched. For example, if set to 3, then up to 3 content are returned. Default value is defined on the scope. |
sort |
array | Used to specify the ordering of the product result. Currently, only the first element will have an effect on the sorting of products. Will sort by score in descending order by default. |
userId |
string | UserId used to enable personalized boost. An id must have a maximal length of 255 characters, can include only digits, English lowercase and uppercase letters and these characters: -_ |
forceSearch |
boolean | When enabled any search optimization will be omitted. E.g. did-you-mean will not be followed. |
splitTestId |
string | SplitTestId is among other things used to select a context. An id must have a maximal length of 255 characters, can include only digits, English lowercase and uppercase letters and these characters: -_ |
pinnedIds |
array | Pinned ids can be used to pin products to the top of a search response. The ids can be sku id or product ids. In order for a product to be pinned the product must match the search request. |
sessionId |
string | The session id of the user making the search. It should be unique and consistent for each event in a session. The session id is optional, but will not contribute to some features in ecommerce search, if not included. |
UnifiedSearchRequestModel in JSON
/api/parameters | |
---|---|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 |
|
Try it yourself
- Use the Unified search endpoint though C# or TS
- Set segment and scope id
- Try a simple search phrase and view results
- Try a search and note the different suggestions
- Make sure scope is set up correctly
- Try different facets and view request/response
- Use the Academy Playground to "play around"
Authenticated search
Most arguments are straightforward; however, the authentication token is crucial for authenticated searches, which are used to limit publicly available data, such as price groups.
The process from a developer's perspective involves:
- Ingesting a price group into SKUs.
- Creating an authenticated scope.
- Generating an authentication token:
- Adding a filter to access the price group
- Performing an authenticated search filtered by the price group.
Please refer to the documentation for more information.
Create a token
You can use this C# code to create a token. It's based on the Getting Started Console App, and you can replace Program.cs with:
Use https://jwt.io/ to view the decoded values.
Try It Yourself: Price group
- Review the price for a specific SKU.
- Create a token with a filter for the VIP price group, and add this to the request
- Review the price for a specific SKU again - it should now display a different price.
Try It Yourself: Authenticated scope
- Create an authenticated scope called
vip
make include a "hidden" field like "VIP level" - See if the scope is accessible without a token
- Create a token and add it to the request
- See if the scope is accessible and the field is included in the response.
Response model
Below is a summary table of the Result Model:
Name | Type | Description |
---|---|---|
products |
array | Products as matched the search. |
facets |
array | Collection of facets. |
suggestions |
array | Suggestions that matched search. Example: "Shorts for women". |
didYouMean |
array | Did you mean, returns a number of examples for search phrases. This can be used to help with spelling errors. Example: "Shorts for women". |
relatedTags |
array | The related tags that matched search. |
numberOfRequestedProductResults |
integer | The number of products that was requested. |
totalProducts |
integer | The total number of products that matched the search. |
totalSuggestions |
integer | The total number of suggestions that matched the search. |
totalRelatedTags |
integer | The total number of related tags that matched the search. |
originalPhrase |
string | The original search phrase. |
usedPhrase |
string | The search phrase that eventually was used. This may be updated if there was not matching products, suggestions and related tags. |
productOffset |
integer | The number of products to skip. Example: 0. |
numberOfRequestedContentResults |
integer | The number of content that was requested. |
totalContent |
integer | The total number of content that matched the search. |
content |
array | Content as matched the search. |
UnifiedSearchResultModel in JSON
/api/parameters | |
---|---|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 |
|
Courier API
The Courier API enables configuration setups for integration with various platforms, including Google Analytics, Raptor, and Bizzkit CMS. For detailed guidance on integration processes, please refer to our documentation.
Info
In the Bizzkit Docker Environment, the Courier API is accessible on port 8023.