How to configure your Elasticsearch

Main configuration

The main setup for your Elasticsearch will be done in the configuration of your application, for example, in an appsettings.json file. Here, you will have to add a section with options for Elasticsearch that should look something like this:

"Ucommerce": {
  "Search": {
    "ElasticClient": {
      "NodePoolType": "Single",
      "AuthenticationType": "None"

The NodePoolType property indicates the type of Elasticsearch setup your application should use and we currently support Single-node and Cloud setups.

With a cloud setup, you will need additional properties to connect to your Elasticsearch cloud instance, for example:

"Ucommerce": {
  "Search": {
    "ElasticClient": {
      "NodePoolType": "Cloud",
      "AuthenticationType": "ApiKey",
      "CloudId": "yourIdHere",
      "ApiKey": "yourApiKey"

The AuthenticationType property indicates the type of authentication used for your setup, the currently supported options are None, ApiKey, and BasicAuthentication.

Adding Elasticsearch to your application

To add Elasticsearch to your application, add the following code to your ucommerceBuilder:


If you need to add extra configuration or just prefer to configure via code, the options overload will allow you to set the same parameters, as shown below:

.AddElasticsearch(options => options.UseInMemoryTransportClient = true);

The options are validated on application startup, so your application will let you know if you add invalid settings.


Here's an overview of what properties are available and what they mean:



Single, Cloud

Determines which type of Elasticsearch setup you're using


None, BasicAuthentication, ApiKey

Determines what type of authentication you're using in your setup.


CloudId from your Elasticsearch Cloud instance.

Connects the setup to your Elasticsearch Cloud instance.


ApiKey from your Elasticsearch instance.

Used for authentication against your Elasticsearch instance.


Uri for your Elasticsearch node, default is http://localhost:9200

Determines the location of your Elasticsearch cluster.


Username for your Elasticsearch user.

Used for basic authentication.


Password for your Elasticsearch user.

Used for basic authentication.


true or false

Determines whether your application should use the in-memory transport client. Can be useful for testing, but is not recommended for production.


An object of type UcommerceSerializerFactory

Can only be set via the options overload in code, used for custom serializer logic.

Last updated