Skip to content

Commit

Permalink
Using API Key to connect Elasticsearch
Browse files Browse the repository at this point in the history
  • Loading branch information
afoucret committed Jan 30, 2024
1 parent cfebb54 commit c07a99d
Showing 1 changed file with 11 additions and 12 deletions.
23 changes: 11 additions & 12 deletions notebooks/learning-to-rank/01-learning-to-rank.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -92,20 +92,19 @@
"import getpass\n",
"from elasticsearch import Elasticsearch\n",
"\n",
"# Found in the \"Manage Deployment\" page\n",
"try:\n",
" CLOUD_ID\n",
"except NameError:\n",
" CLOUD_ID = getpass.getpass(\"Enter Elastic Cloud ID: \")\n",
"\n",
"# Password for the \"elastic\" user generated by Elasticsearch\n",
"try:\n",
" ELASTIC_PASSWORD\n",
"except NameError:\n",
" ELASTIC_PASSWORD = getpass.getpass(\"Enter Elastic password: \")\n",
"# https://www.elastic.co/search-labs/tutorials/install-elasticsearch/elastic-cloud#finding-your-cloud-id\n",
"ELASTIC_CLOUD_ID = getpass(\"Elastic Cloud ID: \")\n",
"\n",
"# https://www.elastic.co/search-labs/tutorials/install-elasticsearch/elastic-cloud#creating-an-api-key\n",
"ELASTIC_API_KEY = getpass(\"Elastic Api Key: \")\n",
"\n",
"# Create the client instance\n",
"es_client = Elasticsearch(cloud_id=CLOUD_ID, basic_auth=(\"elastic\", ELASTIC_PASSWORD))\n",
"es_client = Elasticsearch(\n",
" # For local development\n",
" # hosts=[\"http://localhost:9200\"]\n",
" cloud_id=ELASTIC_CLOUD_ID,\n",
" api_key=ELASTIC_API_KEY,\n",
")\n",
"\n",
"client_info = es_client.info()\n",
"\n",
Expand Down

0 comments on commit c07a99d

Please sign in to comment.