@@ -33,8 +33,8 @@ Language clients are forward compatible; meaning that clients support communicat
33
33
with greater or equal minor versions of Elasticsearch. Elasticsearch language clients
34
34
are only backwards compatible with default distributions and without guarantees made.
35
35
36
- If you have a need to have multiple versions installed at the same time older
37
- versions are also released as ``elasticsearch2 ``, `` elasticsearch5 `` and ``elasticsearch6 ``.
36
+ If you have a need to have multiple versions installed at the same time versions are
37
+ also released, such as ``elasticsearch7 `` and ``elasticsearch8 ``.
38
38
39
39
40
40
Example Usage
@@ -44,25 +44,28 @@ Example Usage
44
44
45
45
from datetime import datetime
46
46
from elasticsearch import Elasticsearch
47
- es = Elasticsearch()
47
+
48
+ es = Elasticsearch(" http://localhost:9200" )
48
49
49
50
doc = {
50
- ' author' : ' kimchy' ,
51
- ' text' : ' Elasticsearch: cool. bonsai cool.' ,
52
- ' timestamp' : datetime.now(),
51
+ " author" : " kimchy" ,
52
+ " text" : " Elasticsearch: cool. bonsai cool." ,
53
+ " timestamp" : datetime.now(),
53
54
}
54
55
resp = es.index(index = " test-index" , id = 1 , document = doc)
55
- print (resp[' result' ])
56
+ print (resp[" result" ])
56
57
57
58
resp = es.get(index = " test-index" , id = 1 )
58
- print (resp[' _source' ])
59
+ print (resp[" _source" ])
59
60
60
61
es.indices.refresh(index = " test-index" )
61
62
62
63
resp = es.search(index = " test-index" , query = {" match_all" : {}})
63
- print (" Got %d Hits:" % resp[' hits' ][' total' ][' value' ])
64
- for hit in resp[' hits' ][' hits' ]:
65
- print (" %(timestamp)s %(author)s : %(text)s " % hit[" _source" ])
64
+ print (" Got {} hits:" .format(resp[" hits" ][" total" ][" value" ]))
65
+ for hit in resp[" hits" ][" hits" ]:
66
+ print (" {timestamp} {author} {text} " .format(** hit[" _source" ]))
67
+
68
+ See more examples in the :ref: `quickstart ` page.
66
69
67
70
68
71
Interactive examples
0 commit comments