def test_multi_threading_update_for_large_score_modifier_fields(self):
        """Test concurrent updates to multiple fields, focusing on ensuring document integrity."""
        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"

        # Add the original document to the index
        self.client.index(self.large_score_modifier_index_name).add_documents(documents=[original_document])
        self.assertEqual(1, self.client.index(self.large_score_modifier_index_name).get_stats()["numberOfDocuments"])

        def randomly_update_document(number_of_updates: int = 50):
            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)

                # Update the document with randomly chosen fields
                self.client.index(self.large_score_modifier_index_name).update_documents(documents=[updated_doc])

        number_of_threads = 10
        updates_per_thread = 50

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

        for thread in threads:
            thread.start()

        for thread in threads:
            thread.join()

        # Retrieve the updated document to ensure it's not broken
        updated_doc = self.client.index(self.large_score_modifier_index_name).get_document("1")
        self.assertEqual(1, self.client.index(self.large_score_modifier_index_name).get_stats()["numberOfDocuments"])
        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 = self.client.index(self.large_score_modifier_index_name).update_documents(documents=[final_doc])

        original_score = self.client.index(self.large_score_modifier_index_name).search(q="test")["hits"][0]["_score"]

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

            modified_score = self.client.index(self.large_score_modifier_index_name).search(q="test",
                score_modifiers=score_modifiers)["hits"][0]["_score"]

            self.assertAlmostEqual(original_score + 1, modified_score, 1)
Test concurrent updates to multiple fields, focusing on ensuring document integrity.
tests/api_tests/v1/tests/api_tests/structured_index/test_partial_update_document.py