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
link: https://github.com/LisaHJung/Part-4-Running-Aggregations-with-Elasticsearch-and-Kibana#set-up-data-within-elasticsearch