diff --git a/document_stores/elasticsearch/src/elasticsearch_haystack/document_store.py b/document_stores/elasticsearch/src/elasticsearch_haystack/document_store.py index 0cf01d311..4f5b23cea 100644 --- a/document_stores/elasticsearch/src/elasticsearch_haystack/document_store.py +++ b/document_stores/elasticsearch/src/elasticsearch_haystack/document_store.py @@ -107,7 +107,7 @@ def _search_documents(self, **kwargs) -> List[Document]: """ top_k = kwargs.get("size") - if top_k is None and 'knn' in kwargs and 'k' in kwargs["knn"]: + if top_k is None and "knn" in kwargs and "k" in kwargs["knn"]: top_k = kwargs["knn"]["k"] documents: List[Document] = [] diff --git a/document_stores/elasticsearch/tests/test_document_store.py b/document_stores/elasticsearch/tests/test_document_store.py index 9376a991d..b35ba6644 100644 --- a/document_stores/elasticsearch/tests/test_document_store.py +++ b/document_stores/elasticsearch/tests/test_document_store.py @@ -1,9 +1,9 @@ # SPDX-FileCopyrightText: 2023-present Silvano Cerza # # SPDX-License-Identifier: Apache-2.0 +import random from typing import List from unittest.mock import patch -import random import pandas as pd import pytest @@ -316,7 +316,7 @@ def test_embedding_retrieval_pagination(self, docstore: ElasticsearchDocumentSto Test that handling of pagination works as expected, when the matching documents are > 10. """ - docs = [Document(content=f"Document {i}", embedding=[random.random() for _ in range(4)]) for i in range(20)] + docs = [Document(content=f"Document {i}", embedding=[random.random() for _ in range(4)]) for i in range(20)] # noqa: S311 docstore.write_documents(docs) results = docstore._embedding_retrieval(query_embedding=[0.1, 0.1, 0.1, 0.1], top_k=11, filters={})