|
47 | 47 | },
|
48 | 48 | {
|
49 | 49 | "cell_type": "code",
|
50 |
| - "execution_count": 55, |
| 50 | + "execution_count": null, |
51 | 51 | "id": "ffc5fa6f",
|
52 | 52 | "metadata": {
|
53 | 53 | "id": "ffc5fa6f"
|
|
71 | 71 | },
|
72 | 72 | {
|
73 | 73 | "cell_type": "code",
|
74 |
| - "execution_count": 9, |
| 74 | + "execution_count": 30, |
75 | 75 | "id": "f38e0397",
|
76 | 76 | "metadata": {
|
77 | 77 | "colab": {
|
|
80 | 80 | "id": "f38e0397",
|
81 | 81 | "outputId": "ad6df489-d242-4229-a42a-39c5ca19d124"
|
82 | 82 | },
|
83 |
| - "outputs": [], |
| 83 | + "outputs": [ |
| 84 | + { |
| 85 | + "name": "stdin", |
| 86 | + "output_type": "stream", |
| 87 | + "text": [ |
| 88 | + "Elastic Cloud ID: ········\n", |
| 89 | + "Elastic Api Key: ········\n" |
| 90 | + ] |
| 91 | + } |
| 92 | + ], |
84 | 93 | "source": [
|
85 | 94 | "from elasticsearch import Elasticsearch\n",
|
86 | 95 | "from getpass import getpass\n",
|
|
122 | 131 | },
|
123 | 132 | {
|
124 | 133 | "cell_type": "code",
|
125 |
| - "execution_count": 10, |
| 134 | + "execution_count": null, |
126 | 135 | "id": "25c618eb",
|
127 | 136 | "metadata": {
|
128 | 137 | "colab": {
|
|
131 | 140 | "id": "25c618eb",
|
132 | 141 | "outputId": "30a6ba5b-5109-4457-ddfe-5633a077ca9b"
|
133 | 142 | },
|
134 |
| - "outputs": [ |
135 |
| - { |
136 |
| - "name": "stdout", |
137 |
| - "output_type": "stream", |
138 |
| - "text": [ |
139 |
| - "{'name': 'instance-0000000011', 'cluster_name': 'd1bd36862ce54c7b903e2aacd4cd7f0a', 'cluster_uuid': 'tIkh0X_UQKmMFQKSfUw-VQ', 'version': {'number': '8.11.1', 'build_flavor': 'default', 'build_type': 'docker', 'build_hash': '6f9ff581fbcde658e6f69d6ce03050f060d1fd0c', 'build_date': '2023-11-11T10:05:59.421038163Z', 'build_snapshot': False, 'lucene_version': '9.8.0', 'minimum_wire_compatibility_version': '7.17.0', 'minimum_index_compatibility_version': '7.0.0'}, 'tagline': 'You Know, for Search'}\n" |
140 |
| - ] |
141 |
| - } |
142 |
| - ], |
| 143 | + "outputs": [], |
143 | 144 | "source": [
|
144 | 145 | "print(client.info())"
|
145 | 146 | ]
|
|
155 | 156 | },
|
156 | 157 | {
|
157 | 158 | "cell_type": "code",
|
158 |
| - "execution_count": 23, |
| 159 | + "execution_count": null, |
159 | 160 | "id": "63560817",
|
160 | 161 | "metadata": {},
|
161 | 162 | "outputs": [],
|
|
185 | 186 | },
|
186 | 187 | {
|
187 | 188 | "cell_type": "code",
|
188 |
| - "execution_count": 24, |
| 189 | + "execution_count": 22, |
189 | 190 | "id": "6bc95238",
|
190 | 191 | "metadata": {
|
191 | 192 | "id": "6bc95238"
|
|
197 | 198 | "ObjectApiResponse({'acknowledged': True})"
|
198 | 199 | ]
|
199 | 200 | },
|
200 |
| - "execution_count": 24, |
| 201 | + "execution_count": 22, |
201 | 202 | "metadata": {},
|
202 | 203 | "output_type": "execute_result"
|
203 | 204 | }
|
|
279 | 280 | },
|
280 | 281 | {
|
281 | 282 | "cell_type": "code",
|
282 |
| - "execution_count": 46, |
| 283 | + "execution_count": 25, |
283 | 284 | "id": "_OAahfg-tqrf",
|
284 | 285 | "metadata": {
|
285 | 286 | "colab": {
|
|
295 | 296 | "ObjectApiResponse({'acknowledged': True, 'shards_acknowledged': True, 'index': 'chunk_passages_example'})"
|
296 | 297 | ]
|
297 | 298 | },
|
298 |
| - "execution_count": 46, |
| 299 | + "execution_count": 25, |
299 | 300 | "metadata": {},
|
300 | 301 | "output_type": "execute_result"
|
301 | 302 | }
|
|
349 | 350 | },
|
350 | 351 | {
|
351 | 352 | "cell_type": "code",
|
352 |
| - "execution_count": 25, |
| 353 | + "execution_count": 26, |
353 | 354 | "id": "008d723e",
|
354 | 355 | "metadata": {
|
355 | 356 | "id": "008d723e"
|
|
395 | 396 | },
|
396 | 397 | {
|
397 | 398 | "cell_type": "code",
|
398 |
| - "execution_count": 42, |
| 399 | + "execution_count": 27, |
399 | 400 | "id": "f12ce2c9",
|
400 | 401 | "metadata": {
|
401 | 402 | "id": "f12ce2c9"
|
|
431 | 432 | "\n",
|
432 | 433 | "To search the data and return what chunk matched the query best you use inner_hits with the knn clause to return just that best matching chunk of the document in the hits output from the query.\n",
|
433 | 434 | "\n",
|
434 |
| - "Below you will see the response which returns the best document and the relevant portion of the larger document text.\n" |
| 435 | + "Below you will see the response which returns the best document and the most relevant passage.\n" |
435 | 436 | ]
|
436 | 437 | },
|
437 | 438 | {
|
438 | 439 | "cell_type": "code",
|
439 |
| - "execution_count": 43, |
| 440 | + "execution_count": 29, |
440 | 441 | "id": "Df7hwcIjYwMT",
|
441 | 442 | "metadata": {
|
442 | 443 | "colab": {
|
|
479 | 480 | "a.\n",
|
480 | 481 | "\n",
|
481 | 482 | "\n",
|
482 |
| - "Score: 0.76643425\n", |
| 483 | + "Score: 0.7664343\n", |
483 | 484 | "\n",
|
484 | 485 | "---\n",
|
485 | 486 | "\n",
|
|
502 | 503 | " index=INDEX_NAME,\n",
|
503 | 504 | " knn={\n",
|
504 | 505 | " \"inner_hits\": {\n",
|
| 506 | + " \"size\": 1,\n", |
505 | 507 | " \"_source\": False,\n",
|
506 | 508 | " \"fields\": [\n",
|
507 | 509 | " \"passages.text\"\n",
|
|
521 | 523 | "\n",
|
522 | 524 | "pretty_response(response)"
|
523 | 525 | ]
|
| 526 | + }, |
| 527 | + { |
| 528 | + "cell_type": "code", |
| 529 | + "execution_count": null, |
| 530 | + "id": "c4bbcc4b-ea2d-47a3-b475-c2eb0eebb7e2", |
| 531 | + "metadata": {}, |
| 532 | + "outputs": [], |
| 533 | + "source": [] |
524 | 534 | }
|
525 | 535 | ],
|
526 | 536 | "metadata": {
|
|
542 | 552 | "name": "python",
|
543 | 553 | "nbconvert_exporter": "python",
|
544 | 554 | "pygments_lexer": "ipython3",
|
545 |
| - "version": "3.11.6" |
| 555 | + "version": "3.10.13" |
546 | 556 | }
|
547 | 557 | },
|
548 | 558 | "nbformat": 4,
|
|
0 commit comments