From 76bce4262955d3460e5b6cadd738cf710a4dbebb Mon Sep 17 00:00:00 2001 From: Geoffrey HARRAZI Date: Sun, 8 Sep 2024 20:58:28 +0200 Subject: [PATCH] docs: Update Google BigQuery Vector Search with new SQL filter feature introduce in langchain-google-community 1.0.9 (#26184) Hello, fix: https://github.com/langchain-ai/langchain/issues/26183 Adding documentation regarding SQL like filter for Google BigQuery Vector Search coming in next langchain-google-community 1.0.9 release. Note: langchain-google-community==1.0.9 is not yet released Question: There is no way to warn the user int the doc about the availability of a feature after a specific package version ? --------- Co-authored-by: Erick Friis --- .../google_bigquery_vector_search.ipynb | 21 ++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/docs/docs/integrations/vectorstores/google_bigquery_vector_search.ipynb b/docs/docs/integrations/vectorstores/google_bigquery_vector_search.ipynb index 8287bb04ca40a..f5cc0e92c4eae 100644 --- a/docs/docs/integrations/vectorstores/google_bigquery_vector_search.ipynb +++ b/docs/docs/integrations/vectorstores/google_bigquery_vector_search.ipynb @@ -325,7 +325,13 @@ "id": "20cf6074081b" }, "source": [ - "### Search for documents with metadata filter" + "### Searching Documents with Metadata Filters\n", + "The vectorstore supports two methods for applying filters to metadata fields when performing document searches:\n", + "\n", + "- Dictionary-based Filters\n", + " - You can pass a dictionary (dict) where the keys represent metadata fields and the values specify the filter condition. This method applies an equality filter between the key and the corresponding value. When multiple key-value pairs are provided, they are combined using a logical AND operation.\n", + "- SQL-based Filters\n", + " - Alternatively, you can provide a string representing an SQL WHERE clause to define more complex filtering conditions. This allows for greater flexibility, supporting SQL expressions such as comparison operators and logical operators." ] }, { @@ -336,11 +342,24 @@ }, "outputs": [], "source": [ + "# Dictionary-based Filters\n", "# This should only return \"Banana\" document.\n", "docs = store.similarity_search_by_vector(query_vector, filter={\"len\": 6})\n", "print(docs)" ] }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# SQL-based Filters\n", + "# This should return \"Banana\", \"Apples and oranges\" and \"Cars and airplanes\" documents.\n", + "docs = store.similarity_search_by_vector(query_vector, filter={\"len = 6 AND len > 17\"})\n", + "print(docs)" + ] + }, { "cell_type": "markdown", "metadata": {