Skip to content

Rename es to client in examples for consistency #2486

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 12 commits into from
Mar 26, 2024

Conversation

iuliaferoli
Copy link
Contributor

Changed examples / docs to only refer to the client instance as client rather than es so we now have uniform naming conventions for clarity.

@iuliaferoli iuliaferoli requested a review from pquentin March 22, 2024 19:22
Copy link

A documentation preview will be available soon.

Request a new doc build by commenting
  • Rebuild this PR: run docs-build
  • Rebuild this PR and all Elastic docs: run docs-build rebuild

run docs-build is much faster than run docs-build rebuild. A rebuild should only be needed in rare situations.

If your PR continues to fail for an unknown reason, the doc build pipeline may be broken. Elastic employees can check the pipeline status here.

Copy link
Member

@pquentin pquentin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work, thanks!

git grep "\bes\b" | grep -v '{es}' | grep -v '^test_elasticsearch' gave three more places to update:

  • scan(es,
    query={"query": {"match": {"title": "python"}}},
    index="orders-*",
    doc_type="books"
    )
  • .. code-block:: python
    async_scan(
    es,
    query={"query": {"match": {"title": "python"}}},
    index="orders-*"
    )
    """
  • from elasticsearch import Elasticsearch
    # Authenticate from the constructor
    es = Elasticsearch(
    "https://localhost:9200",
    ca_certs="/path/to/http_ca.crt",
    basic_auth=("username", "password")
    )
    # Authenticate via the .options() method:
    es.options(
    basic_auth=("username", "password")
    ).indices.get(index="*")
    # You can persist the authenticated client to use
    # later or use for multiple API calls:
    auth_client = es.options(api_key="api_key")
    for i in range(10):
    auth_client.index(
    index="example-index",
    document={"field": i}
    )

@@ -65,22 +65,22 @@ Example Usage
from datetime import datetime
from elasticsearch import Elasticsearch

es = Elasticsearch("http://localhost:9200")
client = Elasticsearch(cloud_id="YOUR_CLOUD_ID", api_key="YOUR_API_KEY")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't want to encourage Cloud IDs which don't really have an advantage over simple endpoints:

Suggested change
client = Elasticsearch(cloud_id="YOUR_CLOUD_ID", api_key="YOUR_API_KEY")
client = Elasticsearch("http://localhost:9200/", api_key="YOUR_API_KEY")

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added those three and made the change you suggested, thanks!

@pquentin pquentin changed the title Iuliaferoli Change es references to client for consistency Rename es to client in examples for consistency Mar 26, 2024
@pquentin pquentin merged commit 794341d into elastic:main Mar 26, 2024
github-actions bot pushed a commit that referenced this pull request Mar 26, 2024
@pquentin pquentin mentioned this pull request Apr 30, 2024
15 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants