Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

400 error for IN filter unstructured #823

Merged
merged 2 commits into from
May 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from marqo.core.unstructured_vespa_index import common as unstructured_common
from marqo.core.unstructured_vespa_index.unstructured_document import UnstructuredVespaDocument
from marqo.core.vespa_index import VespaIndex
from marqo.exceptions import InternalError
from marqo.exceptions import InternalError, InvalidArgumentError


class UnstructuredVespaIndex(VespaIndex):
Expand Down Expand Up @@ -203,6 +203,8 @@ def tree_to_filter_string(node: search_filter.Node) -> str:
return generate_equality_filter_string(node)
elif isinstance(node, search_filter.RangeTerm):
return generate_range_filter_string(node)
elif isinstance(node, search_filter.InTerm):
raise InvalidArgumentError("The 'IN' filter keyword is not yet supported for unstructured indexes")
raise InternalError(f'Unknown node type {type(node)}')

if marqo_query.filter is not None:
Expand Down
25 changes: 25 additions & 0 deletions tests/tensor_search/integ_tests/test_search_combined.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from marqo.tensor_search.enums import SearchMethod
from marqo.tensor_search.models.add_docs_objects import AddDocsParams
from tests.marqo_test import MarqoTestCase
from marqo import exceptions as base_exceptions


class TestSearch(MarqoTestCase):
Expand Down Expand Up @@ -422,6 +423,30 @@ def test_filtering(self):
if expected_ids:
self.assertEqual(set(expected_ids), {hit["_id"] for hit in res["hits"]})

def test_filter_unstructured_index_in_keyword_fails(self):
test_cases = [
"text_field_1 in (random1, true)",
"int_field_1 in (100, 200)",
"long_field_1 in (299, 300)",
"text_field_1 in (random1, true) AND int_field_1:100",
"text_field_1 in (random1, true) OR text_field_2:baaadd",
"text_field_1 in (random1, true) OR int_field_1:[90 TO 210]",
"text_field_1 in (random1)",
"NOT text_field_1 in (random1, true)",
"text_field_1 IN (random1, true) AND int_field_1 in (100, 200)",
"text_field_1 IN ()"
]

for case in test_cases:
with self.subTest(case=case):
with self.assertRaises(base_exceptions.InvalidArgumentError) as cm:
tensor_search.search(config=self.config, index_name=self.unstructured_default_text_index.name,
text="", filter=case)

self.assertIn("'IN' filter keyword is not yet supported for unstructured", str(cm.exception))



def test_filter_id(self):
"""
Test filtering by _id
Expand Down