elastic / eland

Python Client and Toolkit for DataFrames, Big Data, Machine Learning and ETL in Elasticsearch
https://eland.readthedocs.io
Apache License 2.0
628 stars 98 forks source link

Make demo notebook runnable in Colab #630

Closed leemthompo closed 8 months ago

leemthompo commented 8 months ago

Summary:

Related work:

This is a more simplistic approach to https://github.com/elastic/eland/pull/604

Preview in Colab

Visual diff

(Just the opening section — no changes to the actual examples)

leemthompo commented 8 months ago

Should be good now using

def generate_actions(data):
    for idx, entry in enumerate(data, start=0):  # Use monotonically increasing IDs starting from 0
        yield {
            "_index": FLIGHTS_INDEX_NAME,
            "_id": idx,  # Use the current index as the document ID
            "_source": entry
        }