Skip to content

Commit d437a4d

Browse files
committed
Update docs before 8.9.0 release (#1669)
1 parent ce9daac commit d437a4d

File tree

2 files changed

+61
-68
lines changed

2 files changed

+61
-68
lines changed

README

Lines changed: 23 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ Compatibility
3737
The library is compatible with all Elasticsearch versions since ``2.x`` but you
3838
**have to use a matching major version**:
3939

40+
For **Elasticsearch 8.0** and later, use the major version 8 (``8.x.y``) of the
41+
library.
42+
4043
For **Elasticsearch 7.0** and later, use the major version 7 (``7.x.y``) of the
4144
library.
4245

@@ -49,10 +52,12 @@ library.
4952
For **Elasticsearch 2.0** and later, use the major version 2 (``2.x.y``) of the
5053
library.
5154

52-
5355
The recommended way to set your requirements in your `setup.py` or
5456
`requirements.txt` is::
5557

58+
# Elasticsearch 8.x
59+
elasticsearch-dsl>=8.0.0,<9.0.0
60+
5661
# Elasticsearch 7.x
5762
elasticsearch-dsl>=7.0.0,<8.0.0
5863

@@ -66,7 +71,7 @@ The recommended way to set your requirements in your `setup.py` or
6671
elasticsearch-dsl>=2.0.0,<3.0.0
6772

6873

69-
The development is happening on ``master``, older branches only get bugfix releases
74+
The development is happening on ``main``, older branches only get bugfix releases
7075

7176
Search Example
7277
--------------
@@ -76,7 +81,7 @@ Let's have a typical search request written directly as a ``dict``:
7681
.. code:: python
7782

7883
from elasticsearch import Elasticsearch
79-
client = Elasticsearch()
84+
client = Elasticsearch("https://localhost:9200")
8085

8186
response = client.search(
8287
index="my-index",
@@ -118,7 +123,7 @@ Let's rewrite the example using the Python DSL:
118123
from elasticsearch import Elasticsearch
119124
from elasticsearch_dsl import Search
120125

121-
client = Elasticsearch()
126+
client = Elasticsearch("https://localhost:9200")
122127

123128
s = Search(using=client, index="my-index") \
124129
.filter("term", category="search") \
@@ -138,15 +143,11 @@ Let's rewrite the example using the Python DSL:
138143

139144
As you see, the library took care of:
140145

141-
* creating appropriate ``Query`` objects by name (eq. "match")
142-
143-
* composing queries into a compound ``bool`` query
144-
145-
* putting the ``term`` query in a filter context of the ``bool`` query
146-
147-
* providing a convenient access to response data
148-
149-
* no curly or square brackets everywhere
146+
- creating appropriate ``Query`` objects by name (eq. "match")
147+
- composing queries into a compound ``bool`` query
148+
- putting the ``term`` query in a filter context of the ``bool`` query
149+
- providing a convenient access to response data
150+
- no curly or square brackets everywhere
150151

151152

152153
Persistence Example
@@ -160,7 +161,7 @@ Let's have a simple Python class representing an article in a blogging system:
160161
from elasticsearch_dsl import Document, Date, Integer, Keyword, Text, connections
161162

162163
# Define a default Elasticsearch client
163-
connections.create_connection(hosts=['localhost'])
164+
connections.create_connection(hosts="https://localhost:9200")
164165

165166
class Article(Document):
166167
title = Text(analyzer='snowball', fields={'raw': Keyword()})
@@ -200,20 +201,14 @@ Let's have a simple Python class representing an article in a blogging system:
200201

201202
In this example you can see:
202203

203-
* providing a default connection
204-
205-
* defining fields with mapping configuration
206-
207-
* setting index name
208-
209-
* defining custom methods
210-
211-
* overriding the built-in ``.save()`` method to hook into the persistence
212-
life cycle
213-
214-
* retrieving and saving the object into Elasticsearch
215-
216-
* accessing the underlying client for other APIs
204+
- providing a default connection
205+
- defining fields with mapping configuration
206+
- setting index name
207+
- defining custom methods
208+
- overriding the built-in ``.save()`` method to hook into the persistence
209+
life cycle
210+
- retrieving and saving the object into Elasticsearch
211+
- accessing the underlying client for other APIs
217212

218213
You can see more in the persistence chapter of the documentation.
219214

docs/index.rst

Lines changed: 38 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Elasticsearch DSL
33

44
Elasticsearch DSL is a high-level library whose aim is to help with writing and
55
running queries against Elasticsearch. It is built on top of the official
6-
low-level client (``elasticsearch-py``).
6+
low-level client (`elasticsearch-py <https://github.com/elastic/elasticsearch-py>`_).
77

88
It provides a more convenient and idiomatic way to write and manipulate
99
queries. It stays close to the Elasticsearch JSON DSL, mirroring its
@@ -17,6 +17,13 @@ document data in user-defined classes.
1717
To use the other Elasticsearch APIs (eg. cluster health) just use the
1818
underlying client.
1919

20+
Installation
21+
------------
22+
23+
::
24+
25+
pip install elasticsearch-dsl
26+
2027
Examples
2128
--------
2229

@@ -30,6 +37,9 @@ Compatibility
3037
The library is compatible with all Elasticsearch versions since ``2.x`` but you
3138
**have to use a matching major version**:
3239

40+
For **Elasticsearch 8.0** and later, use the major version 8 (``8.x.y``) of the
41+
library.
42+
3343
For **Elasticsearch 7.0** and later, use the major version 7 (``7.x.y``) of the
3444
library.
3545

@@ -45,6 +55,9 @@ library.
4555
The recommended way to set your requirements in your `setup.py` or
4656
`requirements.txt` is::
4757

58+
# Elasticsearch 8.x
59+
elasticsearch-dsl>=8.0.0,<9.0.0
60+
4861
# Elasticsearch 7.x
4962
elasticsearch-dsl>=7.0.0,<8.0.0
5063

@@ -58,7 +71,7 @@ The recommended way to set your requirements in your `setup.py` or
5871
elasticsearch-dsl>=2.0.0,<3.0.0
5972

6073

61-
The development is happening on ``master``, older branches only get bugfix releases
74+
The development is happening on ``main``, older branches only get bugfix releases
6275

6376
Search Example
6477
--------------
@@ -68,20 +81,16 @@ Let's have a typical search request written directly as a ``dict``:
6881
.. code:: python
6982
7083
from elasticsearch import Elasticsearch
71-
client = Elasticsearch()
84+
client = Elasticsearch("https://localhost:9200")
7285
7386
response = client.search(
7487
index="my-index",
7588
body={
7689
"query": {
77-
"filtered": {
78-
"query": {
79-
"bool": {
80-
"must": [{"match": {"title": "python"}}],
81-
"must_not": [{"match": {"description": "beta"}}]
82-
}
83-
},
84-
"filter": {"term": {"category": "search"}}
90+
"bool": {
91+
"must": [{"match": {"title": "python"}}],
92+
"must_not": [{"match": {"description": "beta"}}],
93+
"filter": [{"term": {"category": "search"}}]
8594
}
8695
},
8796
"aggs" : {
@@ -114,7 +123,7 @@ Let's rewrite the example using the Python DSL:
114123
from elasticsearch import Elasticsearch
115124
from elasticsearch_dsl import Search
116125
117-
client = Elasticsearch()
126+
client = Elasticsearch("https://localhost:9200")
118127
119128
s = Search(using=client, index="my-index") \
120129
.filter("term", category="search") \
@@ -134,15 +143,11 @@ Let's rewrite the example using the Python DSL:
134143
135144
As you see, the library took care of:
136145

137-
* creating appropriate ``Query`` objects by name (eq. "match")
138-
139-
* composing queries into a compound ``bool`` query
140-
141-
* creating a ``filtered`` query since ``.filter()`` was used
142-
143-
* providing a convenient access to response data
144-
145-
* no curly or square brackets everywhere
146+
- creating appropriate ``Query`` objects by name (eq. "match")
147+
- composing queries into a compound ``bool`` query
148+
- putting the ``term`` query in a filter context of the ``bool`` query
149+
- providing a convenient access to response data
150+
- no curly or square brackets everywhere
146151

147152

148153
Persistence Example
@@ -153,11 +158,10 @@ Let's have a simple Python class representing an article in a blogging system:
153158
.. code:: python
154159
155160
from datetime import datetime
156-
from elasticsearch_dsl import Document, Date, Integer, Keyword, Text
157-
from elasticsearch_dsl.connections import connections
161+
from elasticsearch_dsl import Document, Date, Integer, Keyword, Text, connections
158162
159163
# Define a default Elasticsearch client
160-
connections.create_connection(hosts=['localhost'])
164+
connections.create_connection(hosts="https://localhost:9200")
161165
162166
class Article(Document):
163167
title = Text(analyzer='snowball', fields={'raw': Keyword()})
@@ -177,7 +181,7 @@ Let's have a simple Python class representing an article in a blogging system:
177181
return super(Article, self).save(** kwargs)
178182
179183
def is_published(self):
180-
return datetime.now() >= self.published_from
184+
return datetime.now() > self.published_from
181185
182186
# create the mappings in elasticsearch
183187
Article.init()
@@ -197,20 +201,14 @@ Let's have a simple Python class representing an article in a blogging system:
197201
198202
In this example you can see:
199203

200-
* providing a :ref:`default connection`
201-
202-
* defining fields with mapping configuration
203-
204-
* setting index name
205-
206-
* defining custom methods
207-
208-
* overriding the built-in ``.save()`` method to hook into the persistence
209-
life cycle
210-
211-
* retrieving and saving the object into Elasticsearch
212-
213-
* accessing the underlying client for other APIs
204+
- providing a default connection
205+
- defining fields with mapping configuration
206+
- setting index name
207+
- defining custom methods
208+
- overriding the built-in ``.save()`` method to hook into the persistence
209+
life cycle
210+
- retrieving and saving the object into Elasticsearch
211+
- accessing the underlying client for other APIs
214212

215213
You can see more in the :ref:`persistence` chapter.
216214

@@ -284,7 +282,7 @@ Writing this as a ``dict``, we would have the following code:
284282
},
285283
)
286284
287-
Using the DSL, we can now express this query as such:
285+
Using the DSL, we can now express this query as such:
288286

289287
.. code:: python
290288

0 commit comments

Comments
 (0)