Skip to content

Commit

Permalink
Fix Sphinx index page
Browse files Browse the repository at this point in the history
It failed to provide an URL when instantiating the client, did not link
to the Quickstart page and generally use older Python idioms.
  • Loading branch information
pquentin committed Nov 13, 2023
1 parent d1b99c8 commit 93fb6fc
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 12 deletions.
25 changes: 14 additions & 11 deletions docs/sphinx/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ Language clients are forward compatible; meaning that clients support communicat
with greater or equal minor versions of Elasticsearch. Elasticsearch language clients
are only backwards compatible with default distributions and without guarantees made.

If you have a need to have multiple versions installed at the same time older
versions are also released as ``elasticsearch2``, ``elasticsearch5`` and ``elasticsearch6``.
If you have a need to have multiple versions installed at the same time versions are
also released, such as ``elasticsearch7`` and ``elasticsearch8``.


Example Usage
Expand All @@ -44,25 +44,28 @@ Example Usage
from datetime import datetime
from elasticsearch import Elasticsearch
es = Elasticsearch()
es = Elasticsearch("http://localhost:9200")
doc = {
'author': 'kimchy',
'text': 'Elasticsearch: cool. bonsai cool.',
'timestamp': datetime.now(),
"author": "kimchy",
"text": "Elasticsearch: cool. bonsai cool.",
"timestamp": datetime.now(),
}
resp = es.index(index="test-index", id=1, document=doc)
print(resp['result'])
print(resp["result"])
resp = es.get(index="test-index", id=1)
print(resp['_source'])
print(resp["_source"])
es.indices.refresh(index="test-index")
resp = es.search(index="test-index", query={"match_all": {}})
print("Got %d Hits:" % resp['hits']['total']['value'])
for hit in resp['hits']['hits']:
print("%(timestamp)s %(author)s: %(text)s" % hit["_source"])
print("Got {} hits:".format(resp["hits"]["total"]["value"]))
for hit in resp["hits"]["hits"]:
print("{timestamp} {author} {text}".format(**hit["_source"]))
See more examples in the :ref:`quickstart` page.


Interactive examples
Expand Down
4 changes: 3 additions & 1 deletion docs/sphinx/quickstart.rst
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
Quickstart
.. _quickstart:

Quickstart
==========

This guide shows you how to install the Elasticsearch Python client and perform basic
Expand Down

0 comments on commit 93fb6fc

Please sign in to comment.