VOOZH about

URL: https://www.nuget.org/packages/Elastic.Esql/

⇱ NuGet Gallery | Elastic.Esql 0.12.0




👁 Image
Elastic.Esql 0.12.0

Prefix Reserved
dotnet add package Elastic.Esql --version 0.12.0
 
 
NuGet\Install-Package Elastic.Esql -Version 0.12.0
 
 
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="Elastic.Esql" Version="0.12.0" />
 
 
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Elastic.Esql" Version="0.12.0" />
 
Directory.Packages.props
<PackageReference Include="Elastic.Esql" />
 
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Elastic.Esql --version 0.12.0
 
 
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Elastic.Esql, 0.12.0"
 
 
#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.
#:package Elastic.Esql@0.12.0
 
 
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Elastic.Esql&version=0.12.0
 
Install as a Cake Addin
#tool nuget:?package=Elastic.Esql&version=0.12.0
 
Install as a Cake Tool
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

Elastic.Esql

Write LINQ, get ES|QL. A pure translation library that converts C# LINQ expressions into Elasticsearch ES|QL query strings. No HTTP dependencies, no transport layer, AOT compatible -- just query generation.

Why?

ES|QL is powerful but building query strings by hand is error-prone. Elastic.Esql lets you write idiomatic C# and get correct, optimized ES|QL -- with full IntelliSense, compile-time checking, and refactoring support.

var esql = new EsqlQueryable<LogEntry>()
 .From("logs-*")
 .Where(l => l.Level == "ERROR" && l.Duration > 1000)
 .OrderByDescending(l => l.Timestamp)
 .Take(50)
 .ToString();

Produces:

FROM logs-*
| WHERE (log.level == "ERROR" AND duration > 1000)
| SORT @timestamp DESC
| LIMIT 50

Quick Start

Translation-only (no Elasticsearch connection needed)

// Reflection-based field resolution
var query = new EsqlQueryable<Order>()
 .From("orders");

// Or with a source-generated JsonSerializerContext -- AOT safe
var provider = new EsqlQueryProvider(MyContext.Default);
query = new EsqlQueryable<Order>(provider)
 .From("orders");

var esql = query
 .Where(o => o.Status == "shipped" && o.Total > 100)
 .OrderByDescending(o => o.CreatedAt)
 .Take(25)
 .ToString();

LINQ query syntax works too

var esql = (
 from o in new EsqlQueryable<Order>().From("orders")
 where o.Status == "shipped"
 where o.Total > 100
 orderby o.CreatedAt descending
 select new { o.Id, o.Total, o.CreatedAt }
).ToString();
FROM orders
| WHERE status == "shipped"
| WHERE total > 100
| SORT created_at DESC
| KEEP id, total, created_at

What Translates?

Filtering

.Where(l => l.StatusCode >= 500) // WHERE statusCode >= 500
.Where(l => l.Level == "ERROR" || l.Level == "FATAL") // WHERE (log.level == "ERROR" OR log.level == "FATAL")
.Where(l => !l.IsResolved) // WHERE NOT isResolved
.Where(l => tags.Contains(l.Tag)) // WHERE tag IN ("a", "b", "c")

Sorting

.OrderBy(l => l.Level).ThenByDescending(l => l.Timestamp) // SORT log.level, @timestamp DESC

Projection

.Select(l => new { l.Message, Secs = l.Duration / 1000 }) // KEEP message | EVAL secs = (duration / 1000)

Aggregation

.GroupBy(l => l.Level)
.Select(g => new {
 Level = g.Key,
 Count = g.Count(),
 AvgDuration = g.Average(l => l.Duration)
})
// STATS count = COUNT(*), avgDuration = AVG(duration) BY level = log.level

String methods

.Where(l => l.Message.Contains("timeout")) // WHERE message LIKE "*timeout*"
.Where(l => l.Host.StartsWith("prod-")) // WHERE host LIKE "prod-*"
.Where(l => string.IsNullOrEmpty(l.Tag)) // WHERE (tag IS NULL OR tag == "")

DateTime -- properties, arithmetic, and static members all translate

.Where(l => l.Timestamp.Year == 2025) // WHERE DATE_EXTRACT("year", @timestamp) == 2025
.Where(l => l.Timestamp > DateTime.UtcNow.AddHours(-1)) // WHERE @timestamp > DATE_ADD("hours", -1, NOW())
.Select(l => new { Hour = l.Timestamp.Hour }) // EVAL hour = DATE_EXTRACT("hour", @timestamp)

Math

.Where(l => Math.Abs(l.Delta) > 0.5) // WHERE ABS(delta) > 0.5
.Select(l => new { Root = Math.Sqrt(l.Value) }) // EVAL root = SQRT(value)

ES|QL-specific functions

using static Elastic.Esql.Functions.EsqlFunctions;

.Where(l => Match(l.Message, "connection error")) // WHERE MATCH(message, "connection error")
.Where(l => CidrMatch(l.ClientIp, "10.0.0.0/8")) // WHERE CIDR_MATCH(client_ip, "10.0.0.0/8")
.Where(l => Like(l.Path, "/api/v?/users")) // WHERE path LIKE "/api/v?/users"

Vector and hybrid search

KNN, TEXT_EMBEDDING, dense vector similarity (V_COSINE, V_DOT_PRODUCT, V_HAMMING, V_L1_NORM, V_L2_NORM), FROM ... METADATA, and FORK + FUSE for hybrid lexical + semantic search are all supported. Vectors are passed as DenseVector<T> (with T = float or T = byte); implicit conversions from T[] and ReadOnlyMemory<T> keep call sites natural, and the bundled JSON converter handles the signed-byte wire format for byte vectors.

// KNN with metadata-driven scoring
.From("books", MetadataField.Score)
.Where(b => EsqlFunctions.Knn(b.Embedding, queryVec, new KnnOptions { K = 10 }))
.OrderByDescending(_ => EsqlMetadata.Score)
// FROM books METADATA _score | WHERE KNN(embedding, [...], { "k": 10 }) | SORT _score DESC

// Hybrid lexical + semantic with FORK + FUSE
.From("books", MetadataField.Id | MetadataField.Index | MetadataField.Score)
.Fork(
 b => b.Where(x => EsqlFunctions.Match(x.Title, "shakespeare")).Take(50),
 b => b.Where(x => EsqlFunctions.Knn(x.TitleVec, queryVec)).Take(50))
.Fuse(method: FuseMethod.Linear, normalizer: ScoreNormalizer.MinMax, weights: [0.7, 0.3])

The MetadataField flags enum selects which document metadata fields to request via the METADATA directive (_id, _score, _source, etc.); the EsqlMetadata static marker class exposes them for use inside Where / OrderBy / Select / Fuse lambdas.

AOT Compatible

Elastic.Esql has no dependency on Elastic.Transport or any HTTP library. The entire translation pipeline -- expression visitors, query model, ES|QL generation -- is pure computation with no reflection-based serialization, no dynamic code generation, and no runtime type emission.

When paired with Elastic.Mapping's source-generated field resolution, the full path from LINQ expression to ES|QL string is AOT safe.

Execution

Elastic.Esql is a pure translation library -- it generates ES|QL strings but does not execute them. Use Elastic.Clients.Esql for the official Elastic.Transport-based execution layer, or subclass EsqlQueryProvider to plug in your own transport:

var provider = new MyCustomQueryProvider(fieldResolver);
var results = await new EsqlQueryable<Order>(provider)
 .From("orders")
 .Where(o => o.Total > 100)
 .ToListAsync();

Without an execution-capable provider, queries translate to strings only -- calling ToListAsync() throws. This is by design.

Works With Elastic.Mapping

When paired with the Elastic.Mapping source generator, field names resolve from your generated mapping context instead of reflection -- fully AOT compatible:

// Field names come from [JsonPropertyName], [Text], [Keyword], etc.
// Aligned with your System.Text.Json source-generated serialization context
var provider = new EsqlQueryProvider(MyContext.Default);
var query = new EsqlQueryable<Product>(provider)
 .From("products")
 .Where(p => p.Name.Contains("laptop")) // Uses generated field name
 .ToString();

Without Elastic.Mapping, field names are resolved via reflection using JsonPropertyName attributes or camelCase convention.

Product Versions Compatible and additional computed target framework versions.
.NET net5.0 net5.0 was computed.  net5.0-windows net5.0-windows was computed.  net6.0 net6.0 was computed.  net6.0-android net6.0-android was computed.  net6.0-ios net6.0-ios was computed.  net6.0-maccatalyst net6.0-maccatalyst was computed.  net6.0-macos net6.0-macos was computed.  net6.0-tvos net6.0-tvos was computed.  net6.0-windows net6.0-windows was computed.  net7.0 net7.0 was computed.  net7.0-android net7.0-android was computed.  net7.0-ios net7.0-ios was computed.  net7.0-maccatalyst net7.0-maccatalyst was computed.  net7.0-macos net7.0-macos was computed.  net7.0-tvos net7.0-tvos was computed.  net7.0-windows net7.0-windows was computed.  net8.0 net8.0 is compatible.  net8.0-android net8.0-android was computed.  net8.0-browser net8.0-browser was computed.  net8.0-ios net8.0-ios was computed.  net8.0-maccatalyst net8.0-maccatalyst was computed.  net8.0-macos net8.0-macos was computed.  net8.0-tvos net8.0-tvos was computed.  net8.0-windows net8.0-windows was computed.  net9.0 net9.0 was computed.  net9.0-android net9.0-android was computed.  net9.0-browser net9.0-browser was computed.  net9.0-ios net9.0-ios was computed.  net9.0-maccatalyst net9.0-maccatalyst was computed.  net9.0-macos net9.0-macos was computed.  net9.0-tvos net9.0-tvos was computed.  net9.0-windows net9.0-windows was computed.  net10.0 net10.0 is compatible.  net10.0-android net10.0-android was computed.  net10.0-browser net10.0-browser was computed.  net10.0-ios net10.0-ios was computed.  net10.0-maccatalyst net10.0-maccatalyst was computed.  net10.0-macos net10.0-macos was computed.  net10.0-tvos net10.0-tvos was computed.  net10.0-windows net10.0-windows was computed. 
.NET Core netcoreapp2.0 netcoreapp2.0 was computed.  netcoreapp2.1 netcoreapp2.1 was computed.  netcoreapp2.2 netcoreapp2.2 was computed.  netcoreapp3.0 netcoreapp3.0 was computed.  netcoreapp3.1 netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 netstandard2.0 is compatible.  netstandard2.1 netstandard2.1 was computed. 
.NET Framework net461 net461 was computed.  net462 net462 was computed.  net463 net463 was computed.  net47 net47 was computed.  net471 net471 was computed.  net472 net472 was computed.  net48 net48 was computed.  net481 net481 was computed. 
MonoAndroid monoandroid monoandroid was computed. 
MonoMac monomac monomac was computed. 
MonoTouch monotouch monotouch was computed. 
Tizen tizen40 tizen40 was computed.  tizen60 tizen60 was computed. 
Xamarin.iOS xamarinios xamarinios was computed. 
Xamarin.Mac xamarinmac xamarinmac was computed. 
Xamarin.TVOS xamarintvos xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (2)

Showing the top 2 NuGet packages that depend on Elastic.Esql:

Package Downloads
Elastic.Clients.Elasticsearch

This strongly-typed, client library enables working with Elasticsearch. It is the official client maintained and supported by Elastic.

Elastic.Clients.Esql

Elasticsearch ES|QL client with LINQ support and HTTP transport

GitHub repositories (1)

Showing the top 1 popular GitHub repositories that depend on Elastic.Esql:

Repository Stars
elastic/elasticsearch-net
This strongly-typed, client library enables working with Elasticsearch. It is the official client maintained and supported by Elastic.
Version Downloads Last Updated
0.12.0 570 5/20/2026
0.11.0 360,887 4/20/2026
0.10.0 635,523 3/24/2026
0.9.0 183 3/20/2026
0.8.0 198 3/18/2026
0.7.0 172 3/17/2026
0.6.0 174 3/11/2026
0.5.0 172 3/11/2026
0.4.1 191 2/18/2026
0.4.0 169 2/17/2026
0.3.0 167 2/16/2026
0.2.0 173 2/12/2026