def test_multi_threading_update(self):
        """Test that we can update documents in multiple threads.

        Note: We are not able to serialise the requests so the order of the updates is not guaranteed. We are only
        ensuring that the documents are not broken after the update."""
        original_document = {
            "text_field": "text field",
            "text_field_filter": "text field filter",
            "text_field_lexical": "text field lexical",
            "text_field_tensor": "text field tensor",
            "int_field": 1,
            "int_field_filter": 2,
            "int_field_score_modifier": 3,
            "float_field": 1.1,
            "float_field_filter": 2.2,
            "bool_field_filter": True,
            "_id": "1"
        }

        self.add_documents(config=self.config, add_docs_params=AddDocsParams(
            index_name=self.structured_index_name,
            docs=[original_document]
        ))

        self.assertEqual(1, self.monitoring.get_index_stats_by_name(self.structured_index_name).number_of_documents)

        def randomly_update_document(number_of_updates: int = 50) -> None:
            updating_fields_pools = {"text_field", "text_field_filter", "text_field_lexical", "text_field_tensor",
                                     "int_field", "int_field_filter", "int_field_score_modifier", "float_field",
                                     "float_field_filter", "bool_field_filter"}

            for _ in range(number_of_updates):
                picked_fields = random.sample(list(updating_fields_pools), 3)

                updated_doc = {
                    "_id": "1"
                }
                for picked_field in picked_fields:

                    if picked_field.startswith("text_field"):
                        updated_doc[picked_field] = "text field" + str(random.randint(1, 100))
                    elif picked_field.startswith("int_field"):
                        updated_doc[picked_field] = np.random.randint(1, 100)
                    elif picked_field.startswith("float_field"):
                        updated_doc[picked_field] = np.random.uniform(1, 100)
                    elif picked_field.startswith("bool_field"):
                        updated_doc[picked_field] = bool(random.getrandbits(1))
                    else:
                        raise ValueError(f"Invalid field name {picked_field}")

                r = update_documents(body_dict={"documents": [updated_doc]},
                                     index_name=self.structured_index_name, marqo_config=self.config)

        number_of_threads = 10
        updates_per_thread = 50

        threads = [threading.Thread(target=randomly_update_document(updates_per_thread),
                                    args=[updates_per_thread]) for _ in range(number_of_threads)]

        for thread in threads:
            thread.start()

        for thread in threads:
            thread.join()

        updated_doc = tensor_search.get_document_by_id(self.config, self.structured_index_name, "1")

        # We only want to ensure the document is not broken after the update
        self.assertEqual(1, self.monitoring.get_index_stats_by_name(self.structured_index_name).number_of_documents)

        self.assertEqual(updated_doc["text_field"].startswith("text field"), True)
        self.assertEqual(updated_doc["text_field_filter"].startswith("text field"), True)
        self.assertEqual(updated_doc["text_field_lexical"].startswith("text field"), True)
        self.assertEqual(updated_doc["text_field_tensor"].startswith("text field"), True)
        self.assertTrue(1 <= updated_doc["int_field"] <= 100)
        self.assertTrue(1 <= updated_doc["int_field_filter"] <= 100)
        self.assertTrue(1 <= updated_doc["int_field_score_modifier"] <= 100)
        self.assertTrue(1 <= updated_doc["float_field"] <= 100)
        self.assertTrue(1 <= updated_doc["float_field_filter"] <= 100)
        self.assertTrue(isinstance(updated_doc["bool_field_filter"], bool))
Test that we can update documents in multiple threads.

        Note: We are not able to serialise the requests so the order of the updates is not guaranteed. We are only
        ensuring that the documents are not broken after the update.
tests/integ_tests/core/document/test_partial_document_update.py