Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add how to transfer data between indices #4

Open
VladimirFokow opened this issue Jun 9, 2023 · 0 comments
Open

add how to transfer data between indices #4

VladimirFokow opened this issue Jun 9, 2023 · 0 comments

Comments

@VladimirFokow
Copy link
Owner

VladimirFokow commented Jun 9, 2023

def transfer_data_to_index(es, ms1, ms2):
    """
    Transfer data from index 'index1' to index 'index2'
    between the timestamps `ms1` and `ms2`.
    """
    body = {
        "source": {
            "index": "index1",
            "query": {
                "range": {
                    "timestamp": {
                        "gte": ms1,
                        "lte": ms2
                    }
                }
            }
        },
        "dest": {
            "index": "index2"
        }
    }
    return es.reindex(body, refresh=True)  
    # `refresh` reindexes the index immediately, so that it can be 
    # queried and the new data will be accessible right away.

link: https://github.com/LisaHJung/Part-4-Running-Aggregations-with-Elasticsearch-and-Kibana#set-up-data-within-elasticsearch

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant