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

reduce k value to result count #219

Merged
merged 2 commits into from
Dec 12, 2022
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/marqo/tensor_search/configs.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,6 @@ def default_env_vars() -> dict:
return {
EnvVars.MARQO_MAX_INDEX_FIELDS: None,
EnvVars.MARQO_MAX_DOC_BYTES: 100000,
EnvVars.MARQO_MAX_RETRIEVABLE_DOCS: None,
EnvVars.MARQO_MAX_RETRIEVABLE_DOCS: 10000,
EnvVars.MARQO_MODELS_TO_PRELOAD: ['hf/all_datasets_v4_MiniLM-L6', "ViT-L/14"]
}
6 changes: 3 additions & 3 deletions src/marqo/tensor_search/tensor_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -732,8 +732,8 @@ def search(config: Config, index_name: str, text: str, result_count: int = 3, hi
"""
max_docs_limit = utils.read_env_vars_and_defaults(EnvVars.MARQO_MAX_RETRIEVABLE_DOCS)
check_upper = True if max_docs_limit is None else result_count <= int(max_docs_limit)
if not(check_upper and result_count >= 0):
upper_bound_explanation = ("The search result limit must be between 0 and the "
if not(check_upper and result_count > 0):
upper_bound_explanation = ("The search result limit must be greater than 0 and less than or equal to the"
f"MARQO_MAX_RETRIEVABLE_DOCS limit of [{max_docs_limit}]. ")
above_zero_explanation = "The search result limit must be greater than or equal to 0."
explanation = upper_bound_explanation if max_docs_limit is not None else above_zero_explanation
Expand Down Expand Up @@ -963,7 +963,7 @@ def _vector_text_search(
"knn": {
f"{TensorField.chunks}.{vector_field}": {
"vector": vectorised_text,
"k": k
"k": result_count
}
}
},
Expand Down
15 changes: 12 additions & 3 deletions tests/tensor_search/test_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,12 +227,21 @@ def test_result_count_validation(self):
raise AssertionError
except IllegalRequestedDocCount as e:
pass
# should work with 0
try:
# should not work with 0
search_res = tensor_search.search(
config=self.config, index_name=self.index_name_1, text="Exact match hehehe",
searchable_attributes=["other field", "Cool Field 1"], return_doc_ids=True, result_count=0
)
raise AssertionError
except IllegalRequestedDocCount as e:
pass
# should work with 1:
search_res = tensor_search.search(
config=self.config, index_name=self.index_name_1, text="Exact match hehehe",
searchable_attributes=["other field", "Cool Field 1"], return_doc_ids=True, result_count=0
searchable_attributes=["other field", "Cool Field 1"], return_doc_ids=True, result_count=1
)
assert len(search_res["hits"]) == 0
assert len(search_res['hits']) >= 1

def test_highlights_tensor(self):
tensor_search.add_documents(
Expand Down