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

multi-instance test compatibility changes #89

Merged
merged 1 commit into from
May 19, 2023
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
43 changes: 43 additions & 0 deletions tests/v0_tests/test_bulk_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,13 @@ def test_search_single(self):
"""
}
add_doc_res = self.client.index(self.index_name_1).add_documents([d1])

if self.IS_MULTI_INSTANCE:
self.warm_request(self.client.bulk_search, [{
"index": self.index_name_1,
"q": "title about some doc"
}])

resp = self.client.bulk_search([{
"index": self.index_name_1,
"q": "title about some doc"
Expand Down Expand Up @@ -89,6 +96,13 @@ def test_search_highlights(self):
({"showHighlights": False}, False),
({"showHighlights": True}, True)
]:

if self.IS_MULTI_INSTANCE:
self.warm_request(self.client.bulk_search, [{**{
"index": self.index_name_1,
"q": "title about some doc"
}, **params}])

resp = self.client.bulk_search([{**{
"index": self.index_name_1,
"q": "title about some doc"
Expand All @@ -112,6 +126,13 @@ def test_search_multi(self):
res = self.client.index(self.index_name_1).add_documents([
d1, d2
])

if self.IS_MULTI_INSTANCE:
self.warm_request(self.client.bulk_search, [{
"index": self.index_name_1,
"q": "this is a solid doc"
}])

resp = self.client.bulk_search([{
"index": self.index_name_1,
"q": "this is a solid doc"
Expand Down Expand Up @@ -139,6 +160,12 @@ def test_select_lexical(self):
d1, d2
])

if self.IS_MULTI_INSTANCE:
self.warm_request(self.client.bulk_search, [{
"index": self.index_name_1,
"q": "Examples of leadership"
}])

# Ensure that vector search works
resp = self.client.bulk_search([{
"index": self.index_name_1,
Expand Down Expand Up @@ -204,6 +231,13 @@ def test_prefiltering(self):
d1, d2
],auto_refresh=True)

if self.IS_MULTI_INSTANCE:
self.warm_request(self.client.bulk_search, [{
"index": self.index_name_1,
"q": "blah blah",
"filter": "(an_int:[0 TO 30] and an_int:2) AND abc-123:(some text)"
}])

resp = self.client.bulk_search([{
"index": self.index_name_1,
"q": "blah blah",
Expand Down Expand Up @@ -237,6 +271,15 @@ def test_attributes_to_retrieve(self):
atts = ["doc title", "an_int"]
for search_method in [enums.SearchMethods.TENSOR,
enums.SearchMethods.LEXICAL]:

if self.IS_MULTI_INSTANCE:
self.warm_request(self.client.bulk_search,[{
"index": self.index_name_1,
"q": "blah blah",
"searchMethod": search_method,
"attributesToRetrieve": atts
}])

resp = self.client.bulk_search([{
"index": self.index_name_1,
"q": "blah blah",
Expand Down
3 changes: 3 additions & 0 deletions tests/v0_tests/test_score_modifier_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ def test_score_modifier_search_results(self):
}]
}

if self.IS_MULTI_INSTANCE:
self.warm_request(self.client.index(self.index_name_1).search, q = self.query, score_modifiers=None, filter_string="filter:original")

original_res = self.client.index(self.index_name_1).search(q = self.query, score_modifiers=None,
filter_string="filter:original")
original_score = original_res["hits"][0]["_score"]
Expand Down
13 changes: 11 additions & 2 deletions tests/v0_tests/test_tensor_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import requests
import random
import math
import time
from tests.marqo_test import MarqoTestCase


Expand Down Expand Up @@ -137,6 +138,7 @@ def test_select_lexical(self):

# Ensure that vector search works
if self.IS_MULTI_INSTANCE:
time.sleep(5)
self.warm_request(self.client.index(self.index_name_1).search,
"Examples of leadership", search_method=enums.SearchMethods.TENSOR)

Expand Down Expand Up @@ -375,9 +377,16 @@ def test_special_characters(self):
add_res = self.client.index(index_name=self.index_name_1).add_documents(
docs, auto_refresh=True, non_tensor_fields=[field_to_not_search]
)
if self.IS_MULTI_INSTANCE:
self.warm_request(self.client.index(self.index_name_1).search, q='Blah')

search_filter_field = f"filter{filter_char}me"
if self.IS_MULTI_INSTANCE:
self.warm_request(self.client.index(self.index_name_1).search,
q="Dog",
searchable_attributes=[field_to_search, field_to_not_search],
attributes_to_retrieve=[field_to_not_search],
filter_string=f'{search_filter_field}:Walrus'
)

search1_res = self.client.index(index_name=self.index_name_1).search(
"Dog", searchable_attributes=[field_to_search, field_to_not_search],
attributes_to_retrieve=[field_to_not_search],
Expand Down