Skip to content

Commit 72d365c

Browse files
committed
Add tests to custom search with matching_strategy param
1 parent 2f75fbe commit 72d365c

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

tests/index/test_index_document_meilisearch.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
# pylint: disable=invalid-name
22

33
from math import ceil
4-
from time import sleep
54
from meilisearch.client import Client
65
from meilisearch.models.document import Document
76
from meilisearch.models.task import TaskInfo

tests/index/test_index_search_meilisearch.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -436,3 +436,29 @@ def test_search_on_nested_documents_with_sortable_attributes(index_with_document
436436
)
437437
assert isinstance(response, dict)
438438
assert response['hits'][0]['id'] == 6
439+
440+
def test_custom_search_params_with_matching_strategy_all(index_with_documents):
441+
"""Tests search with matching strategy param set to all"""
442+
response = index_with_documents().search(
443+
'man loves',
444+
{
445+
'limit': 5,
446+
'matchingStrategy': 'all',
447+
}
448+
)
449+
450+
assert isinstance(response, dict)
451+
assert len(response['hits']) == 1
452+
453+
def test_custom_search_params_with_matching_strategy_last(index_with_documents):
454+
"""Tests search with matching strategy param set to last"""
455+
response = index_with_documents().search(
456+
'man loves',
457+
{
458+
'limit': 5,
459+
'matchingStrategy': 'last',
460+
}
461+
)
462+
463+
assert isinstance(response, dict)
464+
assert len(response['hits']) > 1

0 commit comments

Comments
 (0)