9090 },
9191 {
9292 "cell_type" : " code" ,
93- "execution_count" : null ,
93+ "execution_count" : 48 ,
9494 "metadata" : {
9595 "colab" : {
9696 "base_uri" : " https://localhost:8080/"
9797 },
9898 "id" : " SL47BJNyl3-r" ,
99- "outputId" : " 43588d08-9dfb-4b13-9c42-58e071cf3526 "
99+ "outputId" : " fa707db7-b6ec-47b4-c802-2d14c346e7bd "
100100 },
101101 "outputs" : [
102102 {
103- "name" : " stdout" ,
104103 "output_type" : " stream" ,
104+ "name" : " stdout" ,
105105 "text" : [
106106 " {'acknowledged': True}\n "
107107 ]
108- },
109- {
110- "name" : " stderr" ,
111- "output_type" : " stream" ,
112- "text" : [
113- " <ipython-input-8-5c7708b710af>:44: DeprecationWarning: The 'body' parameter is deprecated and will be removed in a future version. Instead use individual parameters.\n " ,
114- " response = es.ingest.put_pipeline(id=pipeline_id, body=pipeline)\n "
115- ]
116108 }
117109 ],
118110 "source" : [
169161 },
170162 {
171163 "cell_type" : " code" ,
172- "execution_count" : null ,
173- "metadata" : {
174- "colab" : {
175- "base_uri" : " https://localhost:8080/"
176- },
177- "id" : " zNqjEiPZl36N" ,
178- "outputId" : " 55130ac4-042f-4d65-bc4b-08c6527d85d4"
179- },
180- "outputs" : [
181- {
182- "name" : " stdout" ,
183- "output_type" : " stream" ,
184- "text" : [
185- " {'acknowledged': True}\n "
186- ]
187- },
188- {
189- "name" : " stderr" ,
190- "output_type" : " stream" ,
191- "text" : [
192- " <ipython-input-11-40e8294e4183>:34: ElasticsearchWarning: Legacy index templates are deprecated in favor of composable templates.\n " ,
193- " response = es.indices.put_template(name=\" my_vector_index\" ,\n "
194- ]
195- }
196- ],
197164 "source" : [
198165 " index_patterns = [\" my_vector_index-*\" ]\n " ,
199166 " \n " ,
200- " order = 1\n " ,
167+ " priority = 1\n " ,
201168 " \n " ,
202169 " settings = {\n " ,
203- " \" number_of_shards\" : 1,\n " ,
204- " \" number_of_replicas\" : 1,\n " ,
205170 " \" index.default_pipeline\" : pipeline_id,\n " ,
206171 " }\n " ,
207172 " \n " ,
208173 " mappings = {\n " ,
209174 " \" properties\" : {\n " ,
210- " \" my_vector\" : {\n " ,
211- " \" type\" : \" dense_vector\" ,\n " ,
212- " \" dims\" : 768,\n " ,
213- " \" index\" : True,\n " ,
214- " \" similarity\" : \" dot_product\" ,\n " ,
215- " },\n " ,
175+ " \" my_vector\" : {\" type\" : \" dense_vector\" , \" dims\" : 768},\n " ,
216176 " \" my_text\" : {\" type\" : \" text\" },\n " ,
217177 " },\n " ,
218178 " \" _source\" : {\" excludes\" : [\" my_vector\" ]},\n " ,
219179 " }\n " ,
220180 " \n " ,
181+ " # Exclude `my_vector` from `_source` explicitly\n " ,
182+ " source_exclusions = {\" _source\" : {\" excludes\" : [\" my_vector\" ]}}\n " ,
221183 " \n " ,
222- " # Create the index template\n " ,
223- " response = es.indices.put_template (\n " ,
224- " name=\" my_vector_index \" ,\n " ,
184+ " # Create the index template using put_index_template \n " ,
185+ " response = es.indices.put_index_template (\n " ,
186+ " name=\" my_vector_index_template \" , # Template name \n " ,
225187 " index_patterns=index_patterns,\n " ,
226- " order=order,\n " ,
227- " settings=settings,\n " ,
228- " mappings=mappings,\n " ,
188+ " priority=priority,\n " ,
189+ " template={\n " ,
190+ " \" settings\" : settings,\n " ,
191+ " \" mappings\" : mappings,\n " ,
192+ " },\n " ,
229193 " )\n " ,
230194 " \n " ,
231- " \n " ,
232195 " # Print the response\n " ,
233196 " print(response)"
197+ ],
198+ "metadata" : {
199+ "colab" : {
200+ "base_uri" : " https://localhost:8080/"
201+ },
202+ "id" : " I5F6DR8jroEM" ,
203+ "outputId" : " f1222091-cd17-4d8a-d811-2ac8e55d944e"
204+ },
205+ "execution_count" : 49 ,
206+ "outputs" : [
207+ {
208+ "output_type" : " stream" ,
209+ "name" : " stdout" ,
210+ "text" : [
211+ " {'acknowledged': True}\n "
212+ ]
213+ }
234214 ]
235215 },
236216 {
244224 },
245225 {
246226 "cell_type" : " code" ,
247- "execution_count" : null ,
227+ "execution_count" : 50 ,
248228 "metadata" : {
249229 "id" : " XbapSs1c-hkd"
250230 },
255235 },
256236 {
257237 "cell_type" : " code" ,
258- "execution_count" : null ,
238+ "execution_count" : 51 ,
259239 "metadata" : {
260240 "colab" : {
261241 "base_uri" : " https://localhost:8080/"
262242 },
263243 "id" : " bSIJ-AngVmUi" ,
264- "outputId" : " 49074d6e-1d30-44e1-d565-edac0251eae1 "
244+ "outputId" : " c5cdd475-132d-4410-83e8-3557f4e05bb5 "
265245 },
266246 "outputs" : [
267247 {
248+ "output_type" : " execute_result" ,
268249 "data" : {
269250 "text/plain" : [
270251 " ObjectApiResponse({'_shards': {'total': 2, 'successful': 1, 'failed': 0}})"
271252 ]
272253 },
273- "execution_count" : 14 ,
274254 "metadata" : {},
275- "output_type " : " execute_result "
255+ "execution_count " : 51
276256 }
277257 ],
278258 "source" : [
328308 },
329309 {
330310 "cell_type" : " code" ,
331- "execution_count" : null ,
311+ "execution_count" : 52 ,
332312 "metadata" : {
333313 "colab" : {
334314 "base_uri" : " https://localhost:8080/"
335315 },
336316 "id" : " xl76_rM4l3iC" ,
337- "outputId" : " 9a796cf1-4beb-4405-91b9-c323db756d36 "
317+ "outputId" : " 5d3b4c44-ff3c-4489-b850-e2e1bfc4880a "
338318 },
339319 "outputs" : [
340320 {
341- "name" : " stdout" ,
342321 "output_type" : " stream" ,
322+ "name" : " stdout" ,
343323 "text" : [
344- " [{'_id': 'UO5Y3IoB3ljSe18vZY6D ',\n " ,
324+ " [{'_id': 'PoHEcpIB5JwEUwVjEs6E ',\n " ,
345325 " '_index': 'my_vector_index-01',\n " ,
346- " '_score': 0.78170115 ,\n " ,
326+ " '_score': 0.7825787 ,\n " ,
347327 " '_source': {'ml': {'inference': {}},\n " ,
348328 " 'my_metadata': 'The Dude',\n " ,
349329 " 'my_text': \" Hey, careful, man, there's a beverage here!\" }}]\n "
379359 },
380360 {
381361 "cell_type" : " code" ,
382- "execution_count" : null ,
362+ "execution_count" : 53 ,
383363 "metadata" : {
384364 "colab" : {
385365 "base_uri" : " https://localhost:8080/"
386366 },
387367 "id" : " wLY8Q6tEmk06" ,
388- "outputId" : " dc4dd649-3a66-4084-cba1-2e0e51984037 "
368+ "outputId" : " 3f1cc630-6e65-42b8-82eb-b83222fd43ce "
389369 },
390370 "outputs" : [
391371 {
392- "name" : " stdout" ,
393372 "output_type" : " stream" ,
373+ "name" : " stdout" ,
394374 "text" : [
395- " [{'_id': 'U-5Y3IoB3ljSe18vZY6D ',\n " ,
375+ " [{'_id': 'QYHEcpIB5JwEUwVjEs6E ',\n " ,
396376 " '_index': 'my_vector_index-01',\n " ,
397- " '_score': 1.8080788 ,\n " ,
377+ " '_score': 1.8082356 ,\n " ,
398378 " 'fields': {'my_metadata': ['Walter Sobchak'],\n " ,
399379 " 'my_text': ['What do you mean brought it bowling, Dude?']}},\n " ,
400- " {'_id': 'VO5Y3IoB3ljSe18vZY6D ',\n " ,
380+ " {'_id': 'QoHEcpIB5JwEUwVjEs6E ',\n " ,
401381 " '_index': 'my_vector_index-01',\n " ,
402- " '_score': 1.2358729 ,\n " ,
382+ " '_score': 1.2366624 ,\n " ,
403383 " 'fields': {'my_metadata': ['Walter Sobchak'],\n " ,
404384 " 'my_text': ['Donny was a good bowler, and a good man. He was one '\n " ,
405385 " 'of us. He was a man who loved the outdoors... and '\n " ,
447427 },
448428 {
449429 "cell_type" : " code" ,
450- "execution_count" : null ,
430+ "execution_count" : 55 ,
451431 "metadata" : {
452432 "colab" : {
453433 "base_uri" : " https://localhost:8080/"
454434 },
455435 "id" : " yVDMHuM3mla7" ,
456- "outputId" : " ebd848da-8ecc-4683-cb81-719f5a12f815 "
436+ "outputId" : " b39c13de-a97b-4112-b733-a246cdc7f364 "
457437 },
458438 "outputs" : [
459439 {
460- "name" : " stdout" ,
461440 "output_type" : " stream" ,
441+ "name" : " stdout" ,
462442 "text" : [
463- " [{'_id': 'UO5Y3IoB3ljSe18vZY6D ',\n " ,
443+ " [{'_id': 'PoHEcpIB5JwEUwVjEs6E ',\n " ,
464444 " '_index': 'my_vector_index-01',\n " ,
465- " '_score': 0.59285694 ,\n " ,
445+ " '_score': 0.59394693 ,\n " ,
466446 " 'fields': {'my_metadata': ['The Dude'],\n " ,
467447 " 'my_text': [\" Hey, careful, man, there's a beverage here!\" ]}}]\n "
468448 ]
479459 " \" model_text\" : \" Did you bring the dog?\" ,\n " ,
480460 " }\n " ,
481461 " },\n " ,
482- " \" filter\" : {\" term\" : {\" my_metadata\" : \" The Dude\" }},\n " ,
462+ " \" filter\" : {\" term\" : {\" my_metadata.keyword \" : \" The Dude\" }},\n " ,
483463 " }\n " ,
484464 " \n " ,
485465 " fields = [\" my_text\" , \" my_metadata\" ]\n " ,
501481 },
502482 {
503483 "cell_type" : " code" ,
504- "execution_count" : null ,
484+ "execution_count" : 56 ,
505485 "metadata" : {
506486 "colab" : {
507487 "base_uri" : " https://localhost:8080/"
508488 },
509489 "id" : " jbwinE0fm5-I" ,
510- "outputId" : " e8b02f4b-8a89-417f-a892-2e676a812a2d "
490+ "outputId" : " 7ae0af99-3260-475b-98fe-2b5d8d165645 "
511491 },
512492 "outputs" : [
513493 {
514- "name" : " stdout" ,
515494 "output_type" : " stream" ,
495+ "name" : " stdout" ,
516496 "text" : [
517- " [{'_id': 'U-5Y3IoB3ljSe18vZY6D ',\n " ,
497+ " [{'_id': 'QYHEcpIB5JwEUwVjEs6E ',\n " ,
518498 " '_index': 'my_vector_index-01',\n " ,
519- " '_score': 0.74352247 ,\n " ,
499+ " '_score': 0.7433834 ,\n " ,
520500 " 'fields': {'my_metadata': ['Walter Sobchak'],\n " ,
521501 " 'my_text': ['What do you mean brought it bowling, Dude?']}},\n " ,
522- " {'_id': 'UO5Y3IoB3ljSe18vZY6D ',\n " ,
502+ " {'_id': 'PoHEcpIB5JwEUwVjEs6E ',\n " ,
523503 " '_index': 'my_vector_index-01',\n " ,
524- " '_score': 0.6010935 ,\n " ,
504+ " '_score': 0.6028075 ,\n " ,
525505 " 'fields': {'my_metadata': ['The Dude'],\n " ,
526506 " 'my_text': [\" Hey, careful, man, there's a beverage here!\" ]}}]\n "
527507 ]
540520 " },\n " ,
541521 " }\n " ,
542522 " \n " ,
543- " aggs = {\" metadata\" : {\" terms\" : {\" field\" : \" my_metadata\" }}}\n " ,
523+ " aggs = {\" metadata\" : {\" terms\" : {\" field\" : \" my_metadata.keyword \" }}}\n " ,
544524 " \n " ,
545525 " fields = [\" my_text\" , \" my_metadata\" ]\n " ,
546526 " \n " ,
565545 },
566546 "nbformat" : 4 ,
567547 "nbformat_minor" : 0
568- }
548+ }
0 commit comments