Follow our own advice and use kwargs
This commit is contained in:
+5
-7
@@ -12,12 +12,10 @@ Example Usage
|
||||
|
||||
.. testsetup::
|
||||
|
||||
import os
|
||||
from datetime import datetime
|
||||
index_name = os.environ.get('ES_TEST_INDEX', 'test-index')
|
||||
from elasticsearch import Elasticsearch
|
||||
es = Elasticsearch()
|
||||
es.delete_index(index_name, ignore_missing=True)
|
||||
es.delete_index("test_index", ignore_missing=True)
|
||||
|
||||
.. testcode::
|
||||
|
||||
@@ -29,15 +27,15 @@ Example Usage
|
||||
'text': 'Elasticsearch: cool. bonsai cool.',
|
||||
'timestamp': datetime(2010, 10, 10, 10, 10, 10)
|
||||
}
|
||||
res = es.index(index_name, 'tweet', doc, id=1)
|
||||
res = es.index(index="test-index", doc_type='tweet', doc, id=1)
|
||||
print(res['ok'])
|
||||
|
||||
res = es.get(index_name, 1, doc_type='tweet')
|
||||
res = es.get(index="test-index", doc_type='tweet', id=1)
|
||||
print(res['_source'])
|
||||
|
||||
es.refresh(index_name)
|
||||
es.refresh(index="test-index")
|
||||
|
||||
res = es.search('cool', index=index_name)
|
||||
res = es.search(index="test-index", body={"query": {"match_all": {}}})
|
||||
print("Got %d Hits:" % res['hits']['total'])
|
||||
for hit in res['hits']['hits']:
|
||||
print("%(timestamp)s %(author)s: %(text)s" % hit["_source"])
|
||||
|
||||
Reference in New Issue
Block a user