Skip to content

Commit

Permalink
Merge #963
Browse files Browse the repository at this point in the history
963: Fix document and vector fixture r=curquiza a=sanders41

# Pull Request

In looking at #962 I noticed that the `index_with_documents_and_vectors` fixture was not working as expected and therefore the `test_vector_search` test was not testing what was expected. Because only one document had vectors the document addition task was failing and no documents were added to the index. So `test_vector_search` was returning no hits because there were no documents in the index. This updates the fixutre to add vectors to all documents, and updates the test to pass with the new results.

## Related issue
Fixes #<issue_number>

## What does this PR do?
- Fixes the `test_vector_search` test.

## PR checklist
Please check if your PR fulfills the following requirements:
- [ ] Does this PR fix an existing issue, or have you listed the changes applied in the PR description (and why they are needed)?
- [ ] Have you read the contributing guidelines?
- [ ] Have you made sure that the title is accurate and descriptive of the changes?

Thank you so much for contributing to Meilisearch!


Co-authored-by: Paul Sanders <paul@paulsanders.dev>
  • Loading branch information
meili-bors[bot] and sanders41 authored May 22, 2024
2 parents e4c0303 + a2256b2 commit 75860f8
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 2 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,8 @@ def index_maker(index_uid=common.INDEX_UID, documents=small_movies):
@fixture(scope="function")
def index_with_documents_and_vectors(empty_index, small_movies):
small_movies[0]["_vectors"] = {"default": [0.1, 0.2]}
for movie in small_movies[1:]:
movie["_vectors"] = {"default": [0.9, 0.9]}

def index_maker(index_uid=common.INDEX_UID, documents=small_movies):
index = empty_index(index_uid)
Expand Down
2 changes: 1 addition & 1 deletion tests/index/test_index_search_meilisearch.py
Original file line number Diff line number Diff line change
Expand Up @@ -464,4 +464,4 @@ def test_vector_search(index_with_documents_and_vectors):
response = index_with_documents_and_vectors().search(
"", opt_params={"vector": [0.1, 0.2], "hybrid": {"semanticRatio": 1.0}}
)
assert response["hits"] == []
assert len(response["hits"]) > 0

0 comments on commit 75860f8

Please sign in to comment.