def test_approximate_threshold_failures(self):
        """Test approximate threshold parameter failure cases."""
        # Add test documents
        docs = [
            {
                "title": "Test Document 1",
                "content": "This is a test document with some content",
                "_id": "1"
            },
            {
                "title": "Test Document 2",
                "content": "Another test document with different content",
                "_id": "2"
            }
        ]

        for index_name in [self.structured_text_index_name,
                           self.unstructured_text_index_name]:
            with self.subTest(index_name=index_name):
                # Add documents to index
                tensor_fields = (["title", "content"] if
                                 index_name == self.unstructured_text_index_name
                                 else None)
                self.client.index(index_name).add_documents(
                    docs, tensor_fields=tensor_fields
                )

                # Test invalid approximate threshold values for TENSOR and HYBRID
                search_methods = ["TENSOR", "HYBRID"]
                for search_method in search_methods:
                    # Test invalid approximate threshold values (outside 0-1)
                    invalid_thresholds = [-0.1, -1.0, 1.1, 2.0]
                    for threshold in invalid_thresholds:
                        with self.subTest(f"Invalid {search_method} threshold {threshold}"):
                            with self.assertRaises(MarqoWebError) as e:
                                self.client.index(index_name).search(
                                    q="test",
                                    search_method=search_method,
                                    approximate_threshold=threshold
                                )
                            self.assertEqual(e.exception.status_code, 422)
                            self.assertIn(
                                "'approximateThreshold' must be between 0 and 1",
                                str(e.exception))

                # Test that approximate threshold fails for LEXICAL search
                with self.subTest("LEXICAL search with threshold should fail"):
                    with self.assertRaises(MarqoWebError) as e:
                        self.client.index(index_name).search(
                            q="test",
                            search_method="LEXICAL",
                            approximate_threshold=0.5
                        )
                    self.assertEqual(e.exception.status_code, 422)
                    error_msg = str(e.exception)
                    self.assertIn("'approximateThreshold'", error_msg)
                    self.assertIn("HYBRID", error_msg)
                    self.assertIn("TENSOR", error_msg)
Test approximate threshold parameter failure cases.
tests/api_tests/v1/tests/api_tests/test_search_common.py