Skip to content

Commit d1552a4

Browse files
marciwflobernd
andauthored
[DOCS] Add ES|QL doc structure (#8193)
* Add ES|QL doc structure * Tweak TOC * Match TOC * Fix heading levels * Update ESQL document * Small edits --------- Co-authored-by: Florian Bernd <[email protected]>
1 parent 9896ab4 commit d1552a4

File tree

3 files changed

+73
-0
lines changed

3 files changed

+73
-0
lines changed

docs/index.asciidoc

+2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ include::{asciidoc-dir}/../../shared/attributes.asciidoc[]
88
:net-client: Elasticsearch .NET Client
99
:latest-version: 8.1.0
1010

11+
:es-docs: https://www.elastic.co/guide/en/elasticsearch/reference/{branch}
12+
1113
include::intro.asciidoc[]
1214

1315
include::getting-started.asciidoc[]

docs/usage/esql.asciidoc

+69
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
[[esql]]
2+
== ES|QL in the .NET client
3+
++++
4+
<titleabbrev>Using ES|QL</titleabbrev>
5+
++++
6+
7+
This page helps you understand and use {ref}/esql.html[ES|QL] in the
8+
.NET client.
9+
10+
There are two ways to use ES|QL in the .NET client:
11+
12+
* Use the Elasticsearch {es-docs}/esql-apis.html[ES|QL API] directly: This
13+
is the most flexible approach, but it's also the most complex because you must handle
14+
results in their raw form. You can choose the precise format of results,
15+
such as JSON, CSV, or text.
16+
* Use ES|QL high-level helpers: These helpers take care of parsing the raw
17+
response into something readily usable by the application. Several helpers are
18+
available for different use cases, such as object mapping, cursor
19+
traversal of results (in development), and dataframes (in development).
20+
21+
[discrete]
22+
[[esql-how-to]]
23+
=== How to use the ES|QL API
24+
25+
The {es-docs}/esql-query-api.html[ES|QL query API] allows you to specify how
26+
results should be returned. You can choose a
27+
{es-docs}/esql-rest.html#esql-rest-format[response format] such as CSV, text, or
28+
JSON, then fine-tune it with parameters like column separators
29+
and locale.
30+
31+
The following example gets ES|QL results as CSV and parses them:
32+
33+
[source,charp]
34+
----
35+
var response = await client.Esql.QueryAsync(r => r
36+
.Query("FROM index")
37+
.Format("csv")
38+
);
39+
var csvContents = Encoding.UTF8.GetString(response.Data);
40+
----
41+
42+
[discrete]
43+
[[esql-consume-results]]
44+
=== Consume ES|QL results
45+
46+
The previous example showed that although the raw ES|QL API offers maximum
47+
flexibility, additional work is required in order to make use of the
48+
result data.
49+
50+
To simplify things, try working with these three main representations of ES|QL
51+
results (each with its own mapping helper):
52+
53+
* **Objects**, where each row in the results is mapped to an object from your
54+
application domain. This is similar to what ORMs (object relational mappers)
55+
commonly do.
56+
* **Cursors**, where you scan the results row by row and access the data using
57+
column names. This is similar to database access libraries.
58+
* **Dataframes**, where results are organized in a column-oriented structure that
59+
allows efficient processing of column data.
60+
61+
[source,charp]
62+
----
63+
// ObjectAPI example
64+
var response = await client.Esql.QueryAsObjectsAsync<Person>(x => x.Query("FROM index"));
65+
foreach (var person in response)
66+
{
67+
// ...
68+
}
69+
----

docs/usage/index.asciidoc

+2
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,10 @@ If you're new to {es}, make sure also to read {ref}/getting-started.html[Elastic
1010

1111
* <<recommendations, Usage recommendations>>
1212
* <<examples, CRUD usage examples>>
13+
* <<esql, Using ES|QL>>
1314

1415
NOTE: This is still a work in progress, more sections will be added in the near future.
1516

1617
include::recommendations.asciidoc[]
1718
include::examples.asciidoc[]
19+
include::esql.asciidoc[]

0 commit comments

Comments
 (0)