Skip to content

Commit

Permalink
Update hybrid error message (#900)
Browse files Browse the repository at this point in the history
  • Loading branch information
vicilliar committed Jul 18, 2024
1 parent 6b9ea5f commit 465cc8e
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/marqo/core/search/hybrid_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,9 @@ def search(
marqo_index_version = marqo_index.parsed_marqo_version()
if marqo_index_version < constants.MARQO_HYBRID_SEARCH_MINIMUM_VERSION:
raise core_exceptions.UnsupportedFeatureError(
f"Hybrid search is only supported for Marqo indexes with version >= {constants.MARQO_HYBRID_SEARCH_MINIMUM_VERSION}. "
f"Current index version is {marqo_index_version}."
f"Hybrid search is only supported for Marqo indexes created with Marqo "
f"{constants.MARQO_HYBRID_SEARCH_MINIMUM_VERSION} or later. This index was created with Marqo "
f"{marqo_index_version}."
)

# Use default hybrid settings if not provided
Expand Down
17 changes: 17 additions & 0 deletions tests/tensor_search/integ_tests/test_hybrid_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -1274,6 +1274,23 @@ def test_hybrid_search_none_query_with_context_vectors_passes(self):
self.assertEqual("1", r["hits"][1]["_id"])
self.assertTrue(r["hits"][1]["_score"], r["hits"][0]["_score"])

def test_hybrid_search_with_old_version_fails(self):
"""
Hybrid search on an index below version 2.10.0 should fail
"""
index = mock.MagicMock()
index.parsed_marqo_version.return_value = semver.VersionInfo.parse("2.9.0")
with mock.patch("marqo.tensor_search.index_meta_cache.get_index", return_value=index):
with self.assertRaises(core_exceptions.InvalidArgumentError) as e:
tensor_search.search(
config=self.config,
index_name="index_name",
text="dogs",
search_method="HYBRID"
)
self.assertIn(f"Marqo 2.10.0 or later. "
f"This index was created with", str(e.exception))

def test_hybrid_parameters_with_wrong_search_method_fails(self):
"""
Test that hybrid parameters with wrong search method fails.
Expand Down

0 comments on commit 465cc8e

Please sign in to comment.