Update README to clarify the use of elastic user password environment variable (#128045)

- Added instructions for exporting the `ES_LOCAL_PASSWORD` environment variable.
- Updated the `curl` example and Python client example to use `ES_LOCAL_PASSWORD` for consistency.
This commit is contained in:
Mustapha Unubi Momoh 2025-05-14 14:00:23 -04:00 committed by GitHub
parent 85f466207e
commit 9e5cfd080d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -97,6 +97,15 @@ From the `elastic-start-local` folder, check the connection to Elasticsearch usi
source .env source .env
curl $ES_LOCAL_URL -H "Authorization: ApiKey ${ES_LOCAL_API_KEY}" curl $ES_LOCAL_URL -H "Authorization: ApiKey ${ES_LOCAL_API_KEY}"
---- ----
To use the password for the `elastic` user, set and export the `ES_LOCAL_PASSWORD` environment variable. For example:
[source,sh]
----
source .env
export ES_LOCAL_PASSWORD
----
// NOTCONSOLE // NOTCONSOLE
=== Send requests to Elasticsearch === Send requests to Elasticsearch
@ -112,22 +121,23 @@ Here's an example curl command to create a new Elasticsearch index, using basic
[source,sh] [source,sh]
---- ----
curl -u elastic:$ELASTIC_PASSWORD \ curl -u elastic:$ES_LOCAL_PASSWORD \
-X PUT \ -X PUT \
http://localhost:9200/my-new-index \ http://localhost:9200/my-new-index \
-H 'Content-Type: application/json' -H 'Content-Type: application/json'
---- ----
// NOTCONSOLE // NOTCONSOLE
==== Using a language client ==== Using a language client
To connect to your local dev Elasticsearch cluster with a language client, you can use basic authentication with the `elastic` username and the password you set in the environment variable. To connect to your local dev Elasticsearch cluster with a language client, you can use basic authentication with the `elastic` username and the password stored in the `ES_LOCAL_PASSWORD` environment variable.
You'll use the following connection details: You'll use the following connection details:
* **Elasticsearch endpoint**: `http://localhost:9200` * **Elasticsearch endpoint**: `http://localhost:9200`
* **Username**: `elastic` * **Username**: `elastic`
* **Password**: `$ELASTIC_PASSWORD` (Value you set in the environment variable) * **Password**: `$ES_LOCAL_PASSWORD` (Value you set in the environment variable)
For example, to connect with the Python `elasticsearch` client: For example, to connect with the Python `elasticsearch` client:
@ -137,7 +147,7 @@ import os
from elasticsearch import Elasticsearch from elasticsearch import Elasticsearch
username = 'elastic' username = 'elastic'
password = os.getenv('ELASTIC_PASSWORD') # Value you set in the environment variable password = os.getenv('ES_LOCAL_PASSWORD') # Value you set in the environment variable
client = Elasticsearch( client = Elasticsearch(
"http://localhost:9200", "http://localhost:9200",