Configuration

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:

.AddSearch()
.UcommerceBuilder
.AddElasticsearch();

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:

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

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

Properties

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

Last updated