Skip to main content
net10.0

Elasticsearch vector adapter for Koan: index provisioning, kNN search, metadata filtering and health checks via the Elasticsearch REST API.

Published
Jul 22, 2026
3mo ago
Total Downloads
4.0K
3,971

Install

dotnet add package Sylin.Koan.Data.Connector.ElasticSearch --version 0.20.1
ProductVersions
.NET
net10.0

README

Sylin.Koan.Data.Connector.ElasticSearch

Elasticsearch vector storage and similarity search for Koan Entities. Reference the package, keep the application's normal AddKoan() bootstrap, and use Vector<TEntity>; the connector owns discovery, index provisioning, native kNN requests, filtering, naming, source isolation, and readiness participation.

  • Target framework: net10.0
  • License: Apache-2.0

Install

Maturity: Supported 0.20 extension within the capabilities and boundaries below.

dotnet add package Sylin.Koan.Data.Connector.ElasticSearch

Meaningful result

With Elasticsearch reachable, no provider registration or repository scaffold is required:

builder.Services.AddKoan();

public sealed class Article : Entity<Article>
{
    public string Title { get; set; } = "";
}

float[] embedding = [0.12f, 0.42f, 0.88f];
await Vector<Article>.Save("article-1", embedding, new { category = "docs" });

var nearest = await Vector<Article>.Search(
    embedding,
    topK: 5,
    filter: Filter.Eq("category", "docs"));

When Elasticsearch is the intended vector provider, it participates in the shared automatic election policy. If more than one durable provider is referenced, pin business-critical placement with [VectorAdapter("elasticsearch")] or Koan:Data:VectorDefaults:DefaultProvider.

Configuration

auto is the default and uses Koan's health-checked discovery pipeline, then the local endpoint fallback. Use exact provider configuration for secured or explicitly placed clusters:

{
  "ConnectionStrings": {
    "ElasticSearch": "https://search.example.net:9200"
  },
  "Koan": {
    "Data": {
      "ElasticSearch": {
        "ApiKey": "use-your-secret-provider",
        "IndexPrefix": "catalog",
        "Dimension": 1536
      }
    }
  }
}

Koan:Data:ElasticSearch:Endpoint is the exact endpoint alternative to the connection-string entry. HTTP Basic credentials use Username and Password. Credentials belong in the platform's secret store.

Capabilities

  • automatic Elasticsearch dense_vector mapping and index provisioning;
  • single and bulk vector upsert/delete, clear, count, scroll export, and index statistics;
  • native Elasticsearch kNN search with caller-owned topK;
  • metadata filtering pushed into knn.filter, with unsupported operators rejected rather than ignored;
  • source, partition, container, and tenant-aware index naming;
  • selection-aware readiness and redacted startup reporting.

Boundaries

  • This connector stores vector representations and metadata; it is not a general Elasticsearch Entity data adapter.
  • Embedding retrieval and hybrid text/vector search are not supported.
  • All named sources share the configured cluster endpoint and isolate through generated index names. Per-source cluster endpoints are not supported.
  • Setting IndexName explicitly pins all contexts to one index and may defeat active isolation. Koan reports this conflict but honors the explicit name.
  • Automatic discovery probes without credentials. Configure secured clusters explicitly.
  • Elasticsearch index mappings fix the vector dimension at creation. Changing models normally requires a new index or a controlled reindex.

References

Changes from Previous Version

No structural changes between v0.20.0 and v0.20.1.

Adoption Assessment

Assess this package against its supported frameworks, license, maintenance signals and dependency graph before making it a project standard.

Compatibility metadata lists 1 target framework; confirm the exact target used by your application.

Related Guides & Workflows

Learn how to evaluate, integrate, or audit this package in your .NET project.