Skip to content

Commit e8a0302

Browse files
committed
Add LINQ to ESQL documentation
1 parent edf01d2 commit e8a0302

File tree

3 files changed

+521
-21
lines changed

3 files changed

+521
-21
lines changed

docs/reference/esql.md

Lines changed: 7 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,13 @@ mapped_pages:
66

77
# ES|QL in the .NET client [esql]
88

9-
109
This page helps you understand and use [ES|QL](docs-content://explore-analyze/query-filter/languages/esql.md) in the .NET client.
1110

12-
There are two ways to use ES|QL in the .NET client:
11+
The recommended way to work with ES|QL is the [LINQ to ES|QL](linq-to-esql.md) provider, which lets you write type-safe C# LINQ queries that are automatically translated to ES|QL at runtime.
1312

14-
* Use the Elasticsearch [ES|QL API](https://www.elastic.co/docs/api/doc/elasticsearch/group/endpoint-esql) directly: This is the most flexible approach, but it’s also the most complex because you must handle results in their raw form. You can choose the precise format of results, such as JSON, CSV, or text.
15-
* Use ES|QL high-level helpers: These helpers take care of parsing the raw response into something readily usable by the application. Several helpers are available for different use cases, such as object mapping, cursor traversal of results (in development), and dataframes (in development).
13+
For lower-level control, you can also use the Elasticsearch [ES|QL API](https://www.elastic.co/docs/api/doc/elasticsearch/group/endpoint-esql) directly: This is the most flexible approach, but it's also the most complex because you must handle results in their raw form.
1614

15+
You can choose the precise format of results, such as JSON, CSV, or text.
1716

1817
## How to use the ES|QL API [esql-how-to]
1918

@@ -23,28 +22,15 @@ The following example gets ES|QL results as CSV and parses them:
2322

2423
```csharp
2524
var response = await client.Esql.QueryAsync(r => r
26-
.Query("FROM index")
27-
.Format("csv")
25+
.Query("FROM index")
26+
.Format("csv")
2827
);
28+
2929
var csvContents = Encoding.UTF8.GetString(response.Data);
3030
```
3131

32-
3332
## Consume ES|QL results [esql-consume-results]
3433

3534
The previous example showed that although the raw ES|QL API offers maximum flexibility, additional work is required in order to make use of the result data.
3635

37-
To simplify things, try working with these three main representations of ES|QL results (each with its own mapping helper):
38-
39-
* **Objects**, where each row in the results is mapped to an object from your application domain. This is similar to what ORMs (object relational mappers) commonly do.
40-
* **Cursors**, where you scan the results row by row and access the data using column names. This is similar to database access libraries.
41-
* **Dataframes**, where results are organized in a column-oriented structure that allows efficient processing of column data.
42-
43-
```csharp
44-
// ObjectAPI example
45-
var response = await client.Esql.QueryAsObjectsAsync<Person>(x => x.Query("FROM index"));
46-
foreach (var person in response)
47-
{
48-
// ...
49-
}
50-
```
36+
The recommended approach is [LINQ to ES|QL](linq-to-esql.md), which provides type-safe queries with automatic result mapping. See the [LINQ to ES|QL](linq-to-esql.md) documentation for details.

0 commit comments

Comments
 (0)