Skip to content

Commit 39a8ef3

Browse files
Add size to inner_hits, required in 8.13 (#186)
1 parent bd50d62 commit 39a8ef3

File tree

3 files changed

+38
-26
lines changed

3 files changed

+38
-26
lines changed

.github/workflows/tests.yml

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ jobs:
1717
es_stack:
1818
- 8.11.4
1919
- 8.12.0
20+
- 8.13.0-SNAPSHOT
2021
runs-on: ubuntu-latest
2122
services:
2223
elasticsearch:

notebooks/document-chunking/with-index-pipelines.ipynb

+34-24
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
},
4848
{
4949
"cell_type": "code",
50-
"execution_count": 55,
50+
"execution_count": null,
5151
"id": "ffc5fa6f",
5252
"metadata": {
5353
"id": "ffc5fa6f"
@@ -71,7 +71,7 @@
7171
},
7272
{
7373
"cell_type": "code",
74-
"execution_count": 9,
74+
"execution_count": 30,
7575
"id": "f38e0397",
7676
"metadata": {
7777
"colab": {
@@ -80,7 +80,16 @@
8080
"id": "f38e0397",
8181
"outputId": "ad6df489-d242-4229-a42a-39c5ca19d124"
8282
},
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+
],
8493
"source": [
8594
"from elasticsearch import Elasticsearch\n",
8695
"from getpass import getpass\n",
@@ -122,7 +131,7 @@
122131
},
123132
{
124133
"cell_type": "code",
125-
"execution_count": 10,
134+
"execution_count": null,
126135
"id": "25c618eb",
127136
"metadata": {
128137
"colab": {
@@ -131,15 +140,7 @@
131140
"id": "25c618eb",
132141
"outputId": "30a6ba5b-5109-4457-ddfe-5633a077ca9b"
133142
},
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": [],
143144
"source": [
144145
"print(client.info())"
145146
]
@@ -155,7 +156,7 @@
155156
},
156157
{
157158
"cell_type": "code",
158-
"execution_count": 23,
159+
"execution_count": null,
159160
"id": "63560817",
160161
"metadata": {},
161162
"outputs": [],
@@ -185,7 +186,7 @@
185186
},
186187
{
187188
"cell_type": "code",
188-
"execution_count": 24,
189+
"execution_count": 22,
189190
"id": "6bc95238",
190191
"metadata": {
191192
"id": "6bc95238"
@@ -197,7 +198,7 @@
197198
"ObjectApiResponse({'acknowledged': True})"
198199
]
199200
},
200-
"execution_count": 24,
201+
"execution_count": 22,
201202
"metadata": {},
202203
"output_type": "execute_result"
203204
}
@@ -279,7 +280,7 @@
279280
},
280281
{
281282
"cell_type": "code",
282-
"execution_count": 46,
283+
"execution_count": 25,
283284
"id": "_OAahfg-tqrf",
284285
"metadata": {
285286
"colab": {
@@ -295,7 +296,7 @@
295296
"ObjectApiResponse({'acknowledged': True, 'shards_acknowledged': True, 'index': 'chunk_passages_example'})"
296297
]
297298
},
298-
"execution_count": 46,
299+
"execution_count": 25,
299300
"metadata": {},
300301
"output_type": "execute_result"
301302
}
@@ -349,7 +350,7 @@
349350
},
350351
{
351352
"cell_type": "code",
352-
"execution_count": 25,
353+
"execution_count": 26,
353354
"id": "008d723e",
354355
"metadata": {
355356
"id": "008d723e"
@@ -395,7 +396,7 @@
395396
},
396397
{
397398
"cell_type": "code",
398-
"execution_count": 42,
399+
"execution_count": 27,
399400
"id": "f12ce2c9",
400401
"metadata": {
401402
"id": "f12ce2c9"
@@ -431,12 +432,12 @@
431432
"\n",
432433
"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",
433434
"\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"
435436
]
436437
},
437438
{
438439
"cell_type": "code",
439-
"execution_count": 43,
440+
"execution_count": 29,
440441
"id": "Df7hwcIjYwMT",
441442
"metadata": {
442443
"colab": {
@@ -479,7 +480,7 @@
479480
"a.\n",
480481
"\n",
481482
"\n",
482-
"Score: 0.76643425\n",
483+
"Score: 0.7664343\n",
483484
"\n",
484485
"---\n",
485486
"\n",
@@ -502,6 +503,7 @@
502503
" index=INDEX_NAME,\n",
503504
" knn={\n",
504505
" \"inner_hits\": {\n",
506+
" \"size\": 1,\n",
505507
" \"_source\": False,\n",
506508
" \"fields\": [\n",
507509
" \"passages.text\"\n",
@@ -521,6 +523,14 @@
521523
"\n",
522524
"pretty_response(response)"
523525
]
526+
},
527+
{
528+
"cell_type": "code",
529+
"execution_count": null,
530+
"id": "c4bbcc4b-ea2d-47a3-b475-c2eb0eebb7e2",
531+
"metadata": {},
532+
"outputs": [],
533+
"source": []
524534
}
525535
],
526536
"metadata": {
@@ -542,7 +552,7 @@
542552
"name": "python",
543553
"nbconvert_exporter": "python",
544554
"pygments_lexer": "ipython3",
545-
"version": "3.11.6"
555+
"version": "3.10.13"
546556
}
547557
},
548558
"nbformat": 4,

notebooks/document-chunking/with-langchain-splitters.ipynb

+3-2
Original file line numberDiff line numberDiff line change
@@ -377,7 +377,7 @@
377377
"metadata": {},
378378
"source": [
379379
"### Perform a Nested Search\n",
380-
"We can now perform a nested search, to find the passages that match our query, which will be returned in `inner_hits`."
380+
"We can now perform a nested search, to find the passages that match our query, which will be returned in `inner_hits`. In the example that follows only one passage per parent document is requested."
381381
]
382382
},
383383
{
@@ -478,6 +478,7 @@
478478
" index=INDEX_NAME, \n",
479479
" knn={\n",
480480
" \"inner_hits\": {\n",
481+
" \"size\": 1,\n",
481482
" \"_source\": False,\n",
482483
" \"fields\": [\n",
483484
" \"passages.text\"\n",
@@ -644,7 +645,7 @@
644645
"name": "python",
645646
"nbconvert_exporter": "python",
646647
"pygments_lexer": "ipython3",
647-
"version": "3.11.6"
648+
"version": "3.10.13"
648649
}
649650
},
650651
"nbformat": 4,

0 commit comments

Comments
 (0)