def test_multi_threading_update_for_large_score_modifier_fields(self):
        """Test that we can update multiple score modifier fields 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.

        The reason that we are focusing on the score modifier fields is that all the score modifiers are stored in
        a single vespa tensor field, and we are updating the tensor while we update a score modifier field.
        We want to ensure that the score modifier fields are updated correctly and the tensor field is not broken."""

        original_document = {f"float_field_{i}": float(i) for i in range(100)}
        original_document["text_field_tensor"] = "text field tensor"
        original_document["_id"] = "1"

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

        self.assertEqual(1, self.monitoring.get_index_stats_by_name(self.large_score_modifier_index_name) \
                         .number_of_documents)

        def randomly_update_document(number_of_updates: int = 50) -> None:
            updating_fields_pools = [f"float_field_{i}" for i in range(100)]

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

                updated_doc = {
                    "_id": "1"
                }
                for picked_field in picked_fields:
                    updated_doc[picked_field] = np.random.uniform(1, 100)

                r = update_documents(body_dict={"documents": [updated_doc]},
                                     index_name=self.large_score_modifier_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.large_score_modifier_index_name, "1")

        self.assertEqual(1, self.monitoring.get_index_stats_by_name(self.large_score_modifier_index_name). \
                         number_of_documents)
        for i in range(100):
            self.assertTrue(1 <= updated_doc[f"float_field_{i}"] <= 100)

        # Let do a final update and do a score modifier search to ensure the document is not broken
        final_doc = {f"float_field_{i}": 1.0 for i in range(100)}
        final_doc["_id"] = "1"
        r = update_documents(body_dict={"documents": [final_doc]},
                             index_name=self.large_score_modifier_index_name,
                             marqo_config=self.config)

        original_score = tensor_search.search(config=self.config, index_name=self.large_score_modifier_index_name,
                                              text="test")["hits"][0]["_score"]

        for i in range(100):
            score_modifiers = ScoreModifierLists(**{
                "add_to_score": [{"field_name": f"float_field_{i}", "weight": "1.0"}]
            })

            modified_score = tensor_search.search(config=self.config, index_name=self.large_score_modifier_index_name,
                                                  text="test", score_modifiers=score_modifiers)["hits"][0]["_score"]

            self.assertAlmostEqual(original_score + 1, modified_score, 1)
Test that we can update multiple score modifier fields 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.

        The reason that we are focusing on the score modifier fields is that all the score modifiers are stored in
        a single vespa tensor field, and we are updating the tensor while we update a score modifier field.
        We want to ensure that the score modifier fields are updated correctly and the tensor field is not broken.
tests/integ_tests/core/document/test_partial_document_update.py