diff --git a/document_stores/elasticsearch/src/elasticsearch_haystack/document_store.py b/document_stores/elasticsearch/src/elasticsearch_haystack/document_store.py index 7cd9f6d8c..505bf578a 100644 --- a/document_stores/elasticsearch/src/elasticsearch_haystack/document_store.py +++ b/document_stores/elasticsearch/src/elasticsearch_haystack/document_store.py @@ -336,15 +336,11 @@ def _bm25_retrieval( documents = self._search_documents(**body) - if not scale_score: - return documents + if scale_score: + for doc in documents: + doc.score = float(1 / (1 + np.exp(-np.asarray(doc.score / BM25_SCALING_FACTOR)))) - documents_w_scaled_scores = [] - for doc in documents: - doc.score = float(1 / (1 + np.exp(-np.asarray(doc.score / BM25_SCALING_FACTOR)))) - documents_w_scaled_scores.append(doc) - - return documents_w_scaled_scores + return documents def _embedding_retrieval( self,