@@ -44,7 +44,9 @@ Using the client
44
44
----------------
45
45
46
46
Time to use Elasticsearch! This section walks you through the most important
47
- operations of Elasticsearch.
47
+ operations of Elasticsearch. The following examples assume that the Python
48
+ client has already initiated and don't contain the Elasticsearch `include `
49
+ statement.
48
50
49
51
50
52
Creating an index
@@ -54,8 +56,6 @@ This is how you create the `my_index` index:
54
56
55
57
.. code-block :: python
56
58
57
- from elasticsearch import Elasticsearch
58
-
59
59
client.indices.create(index = " my_index" )
60
60
61
61
@@ -66,8 +66,6 @@ This indexes a document with the index API:
66
66
67
67
.. code-block :: python
68
68
69
- from elasticsearch import Elasticsearch
70
-
71
69
client.index(
72
70
index = " my_index" ,
73
71
id = " my_document_id" ,
@@ -84,8 +82,6 @@ Getting documents
84
82
You can get documents by using the following code:
85
83
86
84
.. code-block :: python
87
-
88
- from elasticsearch import Elasticsearch
89
85
90
86
client.get(index = " my_index" , id = " my_document_id" )
91
87
@@ -98,8 +94,6 @@ This is how you can create a single match query with the Python client:
98
94
99
95
.. code-block :: python
100
96
101
- from elasticsearch import Elasticsearch
102
-
103
97
client.search(index = " my_index" , query = {" match" : {" foo" : " foo" }})
104
98
105
99
@@ -110,8 +104,6 @@ This is how you can update a document, for example to add a new field:
110
104
111
105
.. code-block :: python
112
106
113
- from elasticsearch import Elasticsearch
114
-
115
107
client.update(
116
108
index = " my_index" ,
117
109
id = " my_document_id" ,
@@ -126,8 +118,6 @@ Deleting documents
126
118
^^^^^^^^^^^^^^^^^^
127
119
128
120
.. code-block :: python
129
-
130
- from elasticsearch import Elasticsearch
131
121
132
122
client.delete(index = " my_index" , id = " my_document_id" )
133
123
@@ -136,7 +126,5 @@ Deleting an index
136
126
^^^^^^^^^^^^^^^^^
137
127
138
128
.. code-block :: python
139
-
140
- from elasticsearch import Elasticsearch
141
129
142
130
client.indices.delete(index = " my_index" )
0 commit comments