Elasticstretch.DependencyInjection
1.1.2
dotnet add package Elasticstretch.DependencyInjection --version 1.1.2
NuGet\Install-Package Elasticstretch.DependencyInjection -Version 1.1.2
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Elasticstretch.DependencyInjection" Version="1.1.2" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Elasticstretch.DependencyInjection --version 1.1.2
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Elasticstretch.DependencyInjection, 1.1.2"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Elasticstretch.DependencyInjection as a Cake Addin #addin nuget:?package=Elasticstretch.DependencyInjection&version=1.1.2 // Install Elasticstretch.DependencyInjection as a Cake Tool #tool nuget:?package=Elasticstretch.DependencyInjection&version=1.1.2
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Elasticstretch Extensions
Extensions for the Elasticsearch .NET client.
Features
- Inject/resolve Elasticsearch clients using
Microsoft.Extensions.DependencyInjection
. - Configure Elasticsearch clients using
Microsoft.Extensions.Options
. - Load config properties using
Microsoft.Extensions.Configuration
. - Configurable HTTP handlers/logging using
Microsoft.Extensions.Http
.
Installation
Add the NuGet package to your project:
$ dotnet add package Elasticstretch.DependencyInjection
Usage
Resolving clients
Elasticstretch Dependency Injection works out-of-the-box after registering with an IServiceCollection
.
services.AddElasticsearchClient();
services.AddSingleton<MyService>();
Inject the Elasticsearch client via constructor.
public MyService(ElasticsearchClient client)
{
// Client is a singleton managed by the container.
Client = client;
}
Configuring clients
Supported configuration properties are bound to the Elasticsearch
section of .NET configuration providers, such as appsettings.json
.
{
"Elasticsearch": {
"NodeUris": [
"https://node1.example.com:9200",
"https://node2.example.com:9200",
"https://node3.example.com:9200",
"https://node4.example.com:9200",
"https://node5.example.com:9200"
],
"Credentials": {
"ApiKeyId": "elasticstretch",
"ApiKey": "abcdef12345"
},
"UseSniffing": true,
"Randomize": true
}
}
You can also leverage ElasticsearchClientOptions
for additional customization, such as serialization.
services.Configure<ElasticsearchClientOptions>(
options =>
{
options.ConfigureSettings += settings => settings.ThrowExceptions();
options.SourceSerializer =
settings => new DefaultSourceSerializer(settings, x => x.WriteIndented = true);
})
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net6.0
- Elastic.Clients.Elasticsearch (>= 8.9.1)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 7.0.0)
- Microsoft.Extensions.Http (>= 7.0.0)
- Microsoft.Extensions.Options (>= 7.0.1)
- Microsoft.Extensions.Options.ConfigurationExtensions (>= 7.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.