in utils/es.py [0:0]
def copy_from_data_stream(client: Elasticsearch, data_stream_name: str, docs_index: int,settings_mappings_index: int,
max_docs: int):
"""
Given a data stream, it copies the documents retrieved from the given index and places them in a new
index with TSDB enabled.
:param client: ES client.
:param data_stream_name: name of the data stream.
:param docs_index: number of the index to use to retrieve the documents.
:param settings_mappings_index: number of the index to use to get the mappings and settings for the TSDB index.
:param max_docs: maximum documents to be reindexed.
:return: True if the number of documents placed to the TSDB index remained the same. False otherwise.
"""
print("Testing data stream {}.".format(data_stream_name))
if not client.indices.exists(index=data_stream_name):
print("\tData stream {} does not exist. Program will end.".format(data_stream_name))
exit(0)
source_index, mappings, settings = get_tsdb_config(client, data_stream_name, docs_index, settings_mappings_index)
create_index(client, tsdb_index, mappings, settings)
return copy_docs_from_to(client, source_index, tsdb_index, max_docs)