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                
#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                

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 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.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.1.2 29,688 8/11/2023
1.1.1 167 8/11/2023
1.1.0 171 8/10/2023
1.0.0 348 5/29/2023
0.0.1 156 5/28/2023