Skip to content

Commit a3f8cce

Browse files
Expand the overview section of the docs
1 parent 06f25a0 commit a3f8cce

File tree

1 file changed

+77
-23
lines changed

1 file changed

+77
-23
lines changed

docs/reference/index.md

Lines changed: 77 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -9,31 +9,76 @@ mapped_pages:
99

1010
This documentation covers the [official Python client for {{es}}](https://github.com/elastic/elasticsearch-py). The goal of the Python client is to provide common ground for all {{es}}-related code in Python. The client is designed to be unopinionated and extendable.
1111

12-
API reference documentation is provided on [Read the Docs](https://elasticsearch-py.readthedocs.io).
12+
## Example [_example]
1313

14+
::::{tab-set}
15+
16+
:::{tab-item} Standard Python
17+
```python
18+
import os
19+
from elasticsearch import Elasticsearch
20+
21+
def main():
22+
client = Elasticsearch(
23+
hosts=[os.getenv("ELASTICSEARCH_URL")],
24+
api_key=os.getenv("ELASTIC_API_KEY"),
25+
)
26+
27+
resp = client.search(
28+
index="my-index-000001",
29+
from_="40",
30+
size="20",
31+
query={
32+
"term": {
33+
"user.id": "kimchy"
34+
}
35+
},
36+
)
37+
print(resp)
38+
```
39+
:::
1440

15-
The following example shows a simple Python client use case:
1641

42+
:::{tab-item} Standard Python
1743
```python
18-
>>> from datetime import datetime
19-
>>> from elasticsearch import Elasticsearch
44+
import os
45+
from elasticsearch import AsyncElasticsearch
46+
47+
async def main():
48+
client = AsyncElasticsearch(
49+
hosts=[os.getenv("ELASTICSEARCH_URL")],
50+
api_key=os.getenv("ELASTIC_API_KEY"),
51+
)
52+
53+
resp = await client.search(
54+
index="my-index-000001",
55+
from_="40",
56+
size="20",
57+
query={
58+
"term": {
59+
"user.id": "kimchy"
60+
}
61+
},
62+
)
63+
print(resp)
64+
```
65+
:::
2066

21-
# Connect to 'http://localhost:9200'
22-
>>> client = Elasticsearch("http://localhost:9200")
67+
::::
2368

24-
# Datetimes will be serialized:
25-
>>> client.index(index="my-index-000001", id=42, document={"any": "data", "timestamp": datetime.now()})
26-
{'_id': '42', '_index': 'my-index-000001', '_type': 'test-type', '_version': 1, 'ok': True}
69+
## Overview
2770

28-
# ...but not deserialized
29-
>>> client.get(index="my-index-000001", id=42)['_source']
30-
{'any': 'data', 'timestamp': '2013-05-12T19:45:31.804229'}
31-
```
71+
This package is composed of several modules:
3272

73+
### The actual client
3374

75+
This module, sometimes also called the "low-level" client, implements the support for sending requests to {{es}} servers. The client provides access to the entire surface of the {{es}} API.
3476

77+
* [Getting Started guide](getting-started.md)
78+
* [Ingest data with Python walkthrough](docs-content://manage-data/ingest/ingesting-data-from-applications/ingest-data-with-python-on-elasticsearch-service.md)
79+
* [Reference documentation](https://elasticsearch-py.readthedocs.io/en/stable/es_api.html)
3580

36-
## Features [_features]
81+
#### Features [_features]
3782

3883
The client's features include:
3984

@@ -45,19 +90,28 @@ The client's features include:
4590
* Thread safety
4691
* Pluggable architecture
4792

48-
The client also provides a convenient set of [helpers](client-helpers.md) for tasks like bulk indexing and reindexing.
93+
### Bulk helpers
4994

50-
::::{tip}
51-
To get started, try this walkthrough: [Ingest data with Python](docs-content://manage-data/ingest/ingesting-data-from-applications/ingest-data-with-python-on-elasticsearch-service.md)
52-
::::
95+
The bulk helpers are a set of functions that simplify the ingest of large amounts of data through a high-level interface based on Python iterables.
96+
97+
* [User guide](client-helpers.md#bulk-helpers)
98+
* [Reference documentation](https://elasticsearch-py.readthedocs.io/en/stable/api_helpers.html)
99+
100+
### ES|QL query builder
53101

54-
### Elasticsearch Python DSL [_elasticsearch_python_dsl]
102+
This module offers an idiomatic interface to construct ES|QL queries using Python expressions.
55103

56-
The [Python DSL module](../reference/elasticsearch-dsl.md) offers a convenient and idiomatic way to write and manipulate queries.
104+
* [User guide](esql-query-builder.md)
105+
* [Reference documentation](https://elasticsearch-py.readthedocs.io/en/stable/esql.html)
57106

58-
## {{es}} version compatibility [_compatibility]
107+
### DSL module
59108

60-
Language clients are **forward compatible**: each client version works with equivalent and later minor versions of the **same or next major** version of {{es}}. For full compatibility, the client and {{es}} minor versions should match.
109+
The DSL module could be thought of as a "high-level" client for {{es}}. It allows applications to manipulate documents and queries using Python classes and objects instead of primitive types such as dictionaries and lists.
110+
111+
* [User guide](elasticsearch-dsl.md)
112+
* [Reference documentation](https://elasticsearch-py.readthedocs.io/en/stable/dsl.html)
113+
114+
## Compatibility [_compatibility]
61115

62116
| Client version | {{es}} `8.x` | {{es}} `9.x` | {{es}} `10.x` |
63117
|----------------|---------------------------------|---------------------------------|----------------------------------|
@@ -82,4 +136,4 @@ In the Python client, compatibility mode is always enabled.
82136

83137
:::{tip}
84138
To support working with multiple client versions, the Python client is also released under the package names `elasticsearch8` and `elasticsearch9` (to prevent name collisions).
85-
:::
139+
:::

0 commit comments

Comments
 (0)