> For the complete documentation index, see [llms.txt](https://dev.ucommerce.net/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://dev.ucommerce.net/readme/search-and-indexing/configuration.md).

# Configuration

## Main configuration

The main setup for your Elasticsearch will be done in the [configuration](https://learn.microsoft.com/en-us/aspnet/core/fundamentals/configuration/?view=aspnetcore-8.0) 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:

```json
"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:

```json
"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:

```csharp
.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:

```csharp
.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:

<table><thead><tr><th width="271">Property</th><th width="253">Value(s)</th><th>Usage</th></tr></thead><tbody><tr><td>NodePoolType</td><td>Single, Cloud</td><td>Determines which type of Elasticsearch setup you're using</td></tr><tr><td>AuthenticationType</td><td>None, BasicAuthentication, ApiKey</td><td>Determines what type of authentication you're using in your setup.</td></tr><tr><td>CloudId</td><td>CloudId from your Elasticsearch Cloud instance.</td><td>Connects the setup to your Elasticsearch Cloud instance.</td></tr><tr><td>ApiKey</td><td>ApiKey from your Elasticsearch instance.</td><td>Used for authentication against your Elasticsearch instance.</td></tr><tr><td>Uri</td><td>Uri for your Elasticsearch node, default is http://localhost:9200</td><td>Determines the location of your Elasticsearch cluster.</td></tr><tr><td>Username</td><td>Username for your Elasticsearch user.</td><td>Used for basic authentication.</td></tr><tr><td>Password</td><td>Password for your Elasticsearch user.</td><td>Used for basic authentication.</td></tr><tr><td>UseInMemoryTransportClient</td><td>true or false</td><td>Determines whether your application should use the in-memory transport client. Can be useful for testing, but is not recommended for production.</td></tr><tr><td>SerializerFactory</td><td>An object of type UcommerceSerializerFactory</td><td>Can only be set via the options overload in code, used for custom serializer logic.</td></tr><tr><td>WriteChunkSize</td><td>Any number greater than zero</td><td>This is the number of documents that will be written to Elasticsearch in one go.<br>Default is 1000.</td></tr><tr><td>WriteMaxParallelism</td><td>Any number greater than zero</td><td>The maximum number of parallel writes to Elasticsearch.<br>Default is 5.</td></tr></tbody></table>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://dev.ucommerce.net/readme/search-and-indexing/configuration.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
