From 93fb6fc01942e1f615fc3bf74524445dd3132e7f Mon Sep 17 00:00:00 2001 From: Quentin Pradet Date: Mon, 13 Nov 2023 20:33:03 +0400 Subject: [PATCH 1/2] Fix Sphinx index page It failed to provide an URL when instantiating the client, did not link to the Quickstart page and generally use older Python idioms. --- docs/sphinx/index.rst | 25 ++++++++++++++----------- docs/sphinx/quickstart.rst | 4 +++- 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/docs/sphinx/index.rst b/docs/sphinx/index.rst index 307827344..c192c60f1 100644 --- a/docs/sphinx/index.rst +++ b/docs/sphinx/index.rst @@ -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 @@ -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 diff --git a/docs/sphinx/quickstart.rst b/docs/sphinx/quickstart.rst index e21cfe49f..db01edffd 100644 --- a/docs/sphinx/quickstart.rst +++ b/docs/sphinx/quickstart.rst @@ -1,4 +1,6 @@ -Quickstart +.. _quickstart: + +Quickstart ========== This guide shows you how to install the Elasticsearch Python client and perform basic From 439c1202c2b9f0e33bd33a28ad38aace24779c77 Mon Sep 17 00:00:00 2001 From: Quentin Pradet Date: Tue, 14 Nov 2023 06:33:22 +0400 Subject: [PATCH 2/2] Update docs/sphinx/index.rst Co-authored-by: Liam Thompson <32779855+leemthompo@users.noreply.github.com> --- docs/sphinx/index.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/sphinx/index.rst b/docs/sphinx/index.rst index c192c60f1..4a4025b06 100644 --- a/docs/sphinx/index.rst +++ b/docs/sphinx/index.rst @@ -33,7 +33,7 @@ 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 versions are +If you need multiple versions installed at the same time, versions are also released, such as ``elasticsearch7`` and ``elasticsearch8``.