|
25 | 25 | "source": [ |
26 | 26 | "import requests\n", |
27 | 27 | "import json\n", |
28 | | - "import os\n", |
29 | 28 | "\n", |
30 | 29 | "### Download multilingual coco dataset\n", |
31 | 30 | "### Here we are retrieving first 100 rows for this example\n", |
|
54 | 53 | }, |
55 | 54 | { |
56 | 55 | "cell_type": "code", |
57 | | - "execution_count": null, |
| 56 | + "execution_count": 3, |
58 | 57 | "metadata": {}, |
59 | | - "outputs": [], |
| 58 | + "outputs": [ |
| 59 | + { |
| 60 | + "name": "stdout", |
| 61 | + "output_type": "stream", |
| 62 | + "text": [ |
| 63 | + "Enter your Elasticsearch credentials:\n" |
| 64 | + ] |
| 65 | + } |
| 66 | + ], |
60 | 67 | "source": [ |
61 | 68 | "from getpass import getpass\n", |
62 | 69 | "\n", |
63 | 70 | "# Get credentials securely for localhost Elasticsearch\n", |
64 | 71 | "print(\"Enter your Elasticsearch credentials:\")\n", |
65 | | - "cloud_id = input(\"Enter your cloud_id: \")\n", |
66 | | - "api_key = getpass(\"Enter your api_key: \")" |
| 72 | + "elastic_endpoint = input(\"Enter your Elastic endpoint: \")\n", |
| 73 | + "api_key = getpass(\"Enter your API key: \")" |
67 | 74 | ] |
68 | 75 | }, |
69 | 76 | { |
70 | 77 | "cell_type": "code", |
71 | | - "execution_count": null, |
| 78 | + "execution_count": 5, |
72 | 79 | "metadata": {}, |
73 | 80 | "outputs": [ |
74 | 81 | { |
|
77 | 84 | "text": [ |
78 | 85 | "Successfully connected to Elasticsearch\n" |
79 | 86 | ] |
80 | | - }, |
81 | | - { |
82 | | - "name": "stderr", |
83 | | - "output_type": "stream", |
84 | | - "text": [ |
85 | | - "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/elasticsearch/_sync/client/__init__.py:311: SecurityWarning: Connecting to 'https://localhost:9200' using TLS with verify_certs=False is insecure\n", |
86 | | - " _transport = transport_class(\n", |
87 | | - "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/urllib3/connectionpool.py:1099: InsecureRequestWarning: Unverified HTTPS request is being made to host 'localhost'. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#tls-warnings\n", |
88 | | - " warnings.warn(\n" |
89 | | - ] |
90 | 87 | } |
91 | 88 | ], |
92 | 89 | "source": [ |
93 | 90 | "from elasticsearch import Elasticsearch\n", |
94 | 91 | "\n", |
95 | 92 | "try:\n", |
96 | 93 | " es = Elasticsearch(\n", |
97 | | - " hosts=[{\"host\": \"localhost\", \"port\": 9200, \"scheme\": \"https\"}],\n", |
98 | | - " basic_auth=(\"elastic\", \"qaf_admin\"),\n", |
99 | | - " verify_certs=False, # Set to True if you have valid SSL certificates\n", |
100 | | - " # Alternatively, you can use Elastic cloud_id and api_key\n", |
101 | | - " # api_key=getpass(\"API Key: \")\n", |
102 | | - " # cloud_id=getpass(\"Cloud ID: \"),\n", |
| 94 | + " hosts=[elastic_endpoint],\n", |
| 95 | + " api_key=api_key\n", |
103 | 96 | " )\n", |
104 | 97 | "\n", |
105 | 98 | " # Test the connection\n", |
|
116 | 109 | }, |
117 | 110 | { |
118 | 111 | "cell_type": "code", |
119 | | - "execution_count": 16, |
| 112 | + "execution_count": 6, |
120 | 113 | "metadata": {}, |
121 | 114 | "outputs": [ |
122 | 115 | { |
|
126 | 119 | "Successfully bulk indexed 4840 documents\n", |
127 | 120 | "Indexing complete!\n" |
128 | 121 | ] |
129 | | - }, |
130 | | - { |
131 | | - "name": "stderr", |
132 | | - "output_type": "stream", |
133 | | - "text": [ |
134 | | - "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/urllib3/connectionpool.py:1099: InsecureRequestWarning: Unverified HTTPS request is being made to host 'localhost'. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#tls-warnings\n", |
135 | | - " warnings.warn(\n", |
136 | | - "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/urllib3/connectionpool.py:1099: InsecureRequestWarning: Unverified HTTPS request is being made to host 'localhost'. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#tls-warnings\n", |
137 | | - " warnings.warn(\n" |
138 | | - ] |
139 | 122 | } |
140 | 123 | ], |
141 | 124 | "source": [ |
|
227 | 210 | "name": "python", |
228 | 211 | "nbconvert_exporter": "python", |
229 | 212 | "pygments_lexer": "ipython3", |
230 | | - "version": "3.11.6" |
| 213 | + "version": "3.12.10" |
231 | 214 | } |
232 | 215 | }, |
233 | 216 | "nbformat": 4, |
|
0 commit comments