Skip to content
Merged
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
66 changes: 66 additions & 0 deletions tests/index/test_index_search_meilisearch.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,72 @@ def test_custom_search_params_with_string_list(index_with_documents):
assert 'title' in response['hits'][0]['_formatted']
assert 'overview' in response['hits'][0]['_formatted']

def test_custom_search_params_with_crop_marker(index_with_documents):
"""Tests search with a list of one string in query params."""
response = index_with_documents().search(
'dragon',
{
'limit': 1,
'attributesToCrop': ['overview'],
'cropLength': 10,
}
)
assert isinstance(response, dict)
assert len(response['hits']) == 1
assert '_formatted' in response['hits'][0]
assert 'overview' in response['hits'][0]['_formatted']
assert response['hits'][0]['_formatted']['overview'].count(' ') < 10
assert response['hits'][0]['_formatted']['overview'].count('…') == 2

def test_custom_search_params_with_customized_crop_marker(index_with_documents):
"""Tests search with a list of one string in query params."""
response = index_with_documents().search(
'dragon',
{
'limit': 1,
'attributesToCrop': ['overview'],
'cropLength': 10,
'cropMarker': '(ꈍᴗꈍ)',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(ꈍᴗꈍ)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I stole your emojis 😍

}
)
assert isinstance(response, dict)
assert len(response['hits']) == 1
assert '_formatted' in response['hits'][0]
assert 'overview' in response['hits'][0]['_formatted']
assert response['hits'][0]['_formatted']['overview'].count('(ꈍᴗꈍ)') == 2

def test_custom_search_params_with_highlight_tag(index_with_documents):
"""Tests search with a list of one string in query params."""
response = index_with_documents().search(
'dragon',
{
'limit': 1,
'attributesToHighlight': ['*'],
}
)
assert isinstance(response, dict)
assert len(response['hits']) == 1
assert '_formatted' in response['hits'][0]
assert 'title' in response['hits'][0]['_formatted']
assert response['hits'][0]['_formatted']['title'] == 'How to Train Your <em>Dragon</em>: The Hidden World'

def test_custom_search_params_with_customized_highlight_tag(index_with_documents):
"""Tests search with a list of one string in query params."""
response = index_with_documents().search(
'dragon',
{
'limit': 1,
'attributesToHighlight': ['*'],
'highlightPreTag': '(⊃。•́‿•̀。)⊃ ',
'highlightPostTag': ' ⊂(´• ω •`⊂)',
}
)
assert isinstance(response, dict)
assert len(response['hits']) == 1
assert '_formatted' in response['hits'][0]
assert 'title' in response['hits'][0]['_formatted']
assert response['hits'][0]['_formatted']['title'] == 'How to Train Your (⊃。•́‿•̀。)⊃ Dragon ⊂(´• ω •`⊂): The Hidden World'

def test_custom_search_params_with_facets_distribution(index_with_documents):
index = index_with_documents()
update = index.update_filterable_attributes(['genre'])
Expand Down