Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 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
4 changes: 4 additions & 0 deletions .code-samples.meilisearch.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,10 @@ search_parameter_guide_attributes_to_search_on_1: |-
client.index('movies').search('adventure', {
'attributesToSearchOn': ['overview']
})
distinct_attribute_guide_filterable_1: |-
client.index('products').update_filterable_attributes(['product_id', 'sku', 'url'])
distinct_attribute_guide_distinct_parameter_1: |-
client.index('products').search('white shirt', { distinct: 'sku' })
add_movies_json_1: |-
import json

Expand Down
12 changes: 12 additions & 0 deletions tests/index/test_index_search_meilisearch.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# pylint: disable=invalid-name

from typing import Counter

import pytest


Expand Down Expand Up @@ -506,3 +508,13 @@ def test_vector_search(index_with_documents_and_vectors):
"", opt_params={"vector": [0.1, 0.2], "hybrid": {"semanticRatio": 1.0}}
)
assert len(response["hits"]) > 0


def test_search_distinct(index_with_documents):
index_with_documents().update_filterable_attributes(["genre"])
response = index_with_documents().search("with", {"distinct": "genre"})
genres = dict(Counter([x.get("genre") for x in response["hits"]]))
assert isinstance(response, dict)
assert len(response["hits"]) == 11
assert genres == {None: 9, "action": 1, "Sci Fi": 1}
assert response["hits"][0]["id"] == "399579"