|
@@ -308,6 +308,18 @@ class MongodbHandler:
|
|
|
collection_name=input_collection_name,
|
|
|
aggregation_pipeline=aggregation_pipeline)
|
|
|
|
|
|
+ def index_collection(self, collection_name: str, keys: list):
|
|
|
+ """
|
|
|
+ :param keys: compound indexes for the collection,
|
|
|
+ is either a list of tuples of shape (field_name, 1) or (field_name, -1)
|
|
|
+ for the indexing order, or a tuple of field namse, then the second element of the
|
|
|
+ tuple is set to 1
|
|
|
+ """
|
|
|
+ keys = [(key, 1) if not isinstance(key, tuple) else key for key in keys]
|
|
|
+
|
|
|
+ self._database[collection_name].create_index(keys)
|
|
|
+
|
|
|
+
|
|
|
def aggregate_data_and_generate_dataframe(self, collection_name: str, aggregation_pipeline: list, index: str = None, return_as_dataframe=True):
|
|
|
|
|
|
try:
|