Repository: deepset-ai/haystack

Issue:
Enable filtering with BM25 search in Weaviate now that it is supported with v1.18.0
**Is your feature request related to a problem? Please describe.**
Filtering with BM25 search was not supported prior to Weaviate v1.18.0, but with this version now it is supported in Weaviate, so we need to support it from Haystack when the Weaviate document store is used.

**Describe the solution you'd like**
I have made comments in the code before regarding the places where changes need to be made once this becomes available in Weaviate, so now we just need to uncomment those to make this work.

**Describe alternatives you've considered**
N/A

**Additional context**
I will submit a PR for this.



Discussion:

Resolving patch:
diff --git a/haystack/document_stores/weaviate.py b/haystack/document_stores/weaviate.py
--- a/haystack/document_stores/weaviate.py
+++ b/haystack/document_stores/weaviate.py
@@ -999,29 +999,16 @@ def query(
 
         # Default Retrieval via BM25 using the user's query on `self.content_field`
         else:
-            logger.warning(
-                "As of v1.14.1 Weaviate's BM25 retrieval is still in experimental phase, "
-                "so use it with care! To turn on the BM25 experimental feature in Weaviate "
-                "you need to start it with the `ENABLE_EXPERIMENTAL_BM25='true'` "
-                "environmental variable."
-            )
-
             # Retrieval with BM25 AND filtering
-            if filters:  # pylint: disable=no-else-raise
-                raise NotImplementedError(
-                    "Weaviate currently does not support filters WITH inverted index text query (eg BM25)!"
+            if filters:
+                filter_dict = LogicalFilterClause.parse(filters).convert_to_weaviate()
+                gql_query = (
+                    gql.get.GetBuilder(class_name=index, properties=properties, connection=self.weaviate_client)
+                    .with_limit(top_k)
+                    .with_bm25({"query": query, "properties": self.content_field})
+                    .with_where(filter_dict)
+                    .build()
                 )
-                # # Once Weaviate starts supporting filters with BM25:
-                # filter_dict = LogicalFilterClause.parse(filters).convert_to_weaviate()
-                # gql_query = (
-                #     weaviate.gql.get.GetBuilder(
-                #         class_name=index, properties=properties, connection=self.weaviate_client
-                #     )
-                #     .with_near_vector({"vector": [0, 0]})
-                #     .with_where(filter_dict)
-                #     .with_limit(top_k)
-                #     .build()
-                # )
             else:
                 # BM25 retrieval without filtering
                 gql_query = (


Test patch:
diff --git a/test/nodes/test_retriever.py b/test/nodes/test_retriever.py
--- a/test/nodes/test_retriever.py
+++ b/test/nodes/test_retriever.py
@@ -83,8 +83,7 @@ def test_retrieval_without_filters(retriever_with_docs: BaseRetriever, document_
         ("embedding", "elasticsearch"),
         ("embedding", "memory"),
         ("bm25", "elasticsearch"),
-        # TODO - add once Weaviate starts supporting filters with BM25 in Weaviate v1.18+
-        # ("bm25", "weaviate"),
+        ("bm25", "weaviate"),
         ("es_filter_only", "elasticsearch"),
     ],
     indirect=True,