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:
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:
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:
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:
Property | Value(s) | Usage |
---|---|---|
NodePoolType | Single, Cloud | Determines which type of Elasticsearch setup you're using |
AuthenticationType | None, BasicAuthentication, ApiKey | Determines what type of authentication you're using in your setup. |
CloudId | CloudId from your Elasticsearch Cloud instance. | Connects the setup to your Elasticsearch Cloud instance. |
ApiKey | ApiKey from your Elasticsearch instance. | Used for authentication against your Elasticsearch instance. |
Uri | Uri for your Elasticsearch node, default is http://localhost:9200 | Determines the location of your Elasticsearch cluster. |
Username | Username for your Elasticsearch user. | Used for basic authentication. |
Password | Password for your Elasticsearch user. | Used for basic authentication. |
UseInMemoryTransportClient | 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. |
SerializerFactory | An object of type UcommerceSerializerFactory | Can only be set via the options overload in code, used for custom serializer logic. |
Last updated