in ees_microsoft_teams/sync_enterprise_search.py [0:0]
def index_documents(self, documents):
"""This method indexes the documents to the workplace.
:param documents: Documents to be indexed into the Workplace Search
"""
if documents:
total_records_dict = self.get_records_by_types(documents)
for chunk in split_list_into_buckets(documents, constant.BATCH_SIZE):
try:
response = self.workplace_search_custom_client.index_documents(
chunk, constant.CONNECTION_TIMEOUT
)
except IndexingError as exception:
raise IndexingError(exception)
for result in response["results"]:
if result["errors"]:
failed_document_list = self.fetch_documents_by_id(result, documents)
# Removing the failed document from the successfully indexed document count
documents = [document for document in documents if document not in failed_document_list]
self.logger.error(
f"Error while indexing {result['id']}. Error: {result['errors']}"
)
total_inserted_record_dict = self.get_records_by_types(documents)
for type, count in total_records_dict.items():
self.logger.info(f"Total {total_inserted_record_dict[type]} {type} indexed out of "
f"{count}." if total_inserted_record_dict else f"Total 0 {type} "
f"indexed out of {count}")