Skip to content

Commit 7d55f67

Browse files
committed
docs(query-agent): make search-mode filtering a required argument
The Query Agent service now requires the search-mode `filtering` argument to be "recall" or "precision"; the latest client (weaviate-agents 1.6.0) still defaults it to None and sends null, so every `.search()` call that omits `filtering` fails with a 422. Document `filtering` as required (recommending "recall") and pass `filtering="recall"` in every initial search-mode snippet (Python + TypeScript); the precision FilteringExample and pagination/ask calls are unchanged.
1 parent 4998f52 commit 7d55f67

10 files changed

Lines changed: 27 additions & 8 deletions

File tree

_includes/code/llms-txt/python/query_agent.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
print(response.final_answer)
2929

3030
# Retrieval only (no generation)
31-
search_response = qa.search("sci-fi movies", limit=5)
31+
search_response = qa.search("sci-fi movies", filtering="recall", limit=5)
3232
# END llms_query_agent
3333

3434
assert response.final_answer

_includes/code/python/quickstart.short.query_agent.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
qa = QueryAgent(client=client, collections=["Movie"])
1919

2020
# Step 2.3: Perform a query using Search Mode
21-
response = qa.search("Find a cool sci-fi movie.", limit=1)
21+
response = qa.search("Find a cool sci-fi movie.", filtering="recall", limit=1)
2222
# highlight-end
2323

2424
# Print the response

docs/query-agent/_includes/code/query_agent.mts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ clothingResponse.display();
141141
// START BasicSearchQuery
142142
// Perform a search using Search Mode (retrieval only, no answer generation)
143143
const basicSearchResponse = await qa.search("Find me some vintage shoes under $70", {
144+
filtering: "recall",
144145
limit: 10
145146
})
146147

@@ -154,6 +155,7 @@ for (const obj of basicSearchResponse.searchResults.objects) {
154155
// Diversity ranking needs a vectorizer it can resolve. Scope the call to a
155156
// single collection with a target vector so the agent knows what to use.
156157
const diversitySearchResponse = await qa.search("summer shoes", {
158+
filtering: "recall",
157159
limit: 10,
158160
diversityWeight: 0.5,
159161
collections: [{
@@ -179,6 +181,7 @@ basicResponse.display();
179181
// START SearchModeResponseStructure
180182
// SearchModeResponse structure for TypeScript
181183
const searchResponse = await qa.search("winter boots for under $100", {
184+
filtering: "recall",
182185
limit: 5
183186
})
184187

@@ -206,6 +209,7 @@ for (const obj of searchResponse.searchResults.objects) {
206209
// Search with pagination
207210
const responsePage1 = await qa.search(
208211
"Find summer shoes and accessories between $50 and $100 that have the tag 'sale'", {
212+
filtering: "recall",
209213
limit: 3,
210214
})
211215

docs/query-agent/_includes/code/query_agent.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@
211211

212212
# START BasicSearchQuery
213213
# Perform a search using Search Mode (retrieval only, no answer generation)
214-
search_response = qa.search("Find me some vintage shoes under $70", limit=10)
214+
search_response = qa.search("Find me some vintage shoes under $70", filtering="recall", limit=10)
215215

216216
# Access the search results
217217
for obj in search_response.search_results.objects:
@@ -220,7 +220,7 @@
220220

221221
# START SearchModeResponseStructure
222222
# SearchModeResponse structure for Python
223-
search_response = qa.search("winter boots for under $100", limit=5)
223+
search_response = qa.search("winter boots for under $100", filtering="recall", limit=5)
224224

225225
# Access different parts of the response
226226
print(f"Original query: {search_response.searches[0].query}")
@@ -244,6 +244,7 @@
244244
# Search with pagination
245245
response_page_1 = qa.search(
246246
"Find summer shoes and accessories between $50 and $100 that have the tag 'sale'",
247+
filtering="recall",
247248
limit=3,
248249
)
249250

@@ -269,6 +270,7 @@
269270
# START DiversityRanking
270271
search_response = qa.search(
271272
"summer shoes",
273+
filtering="recall",
272274
limit=10,
273275
diversity_weight=0.5,
274276
collections=[

docs/query-agent/_includes/code/query_agent_get_started.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@
135135
# START SearchMode
136136
search_response = agent.search(
137137
"Find me some vintage shoes under $70",
138+
filtering="recall",
138139
limit=10,
139140
)
140141

docs/query-agent/_includes/code/quickstart.mts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ qa = new QueryAgent(client, {
5151
// START BasicSearchQuery
5252
const searchResponse = await qa.search(
5353
"Find me some vintage shoes under $70", {
54+
filtering: "recall",
5455
limit: 10,
5556
});
5657
// END BasicSearchQuery

docs/query-agent/_includes/code/quickstart.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,8 @@
5353

5454
# START BasicSearchQuery
5555
search_response = qa.search(
56-
"Find me some vintage shoes under $70",
56+
"Find me some vintage shoes under $70",
57+
filtering="recall",
5758
limit=10
5859
)
5960
# END BasicSearchQuery

docs/query-agent/_includes/code/search_mode.mts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ await populateWeaviate(client);
3939

4040
// START BasicSearchMode
4141
const searchResponse = await qa.search("Find me some vintage shoes under $70", {
42+
filtering: "recall",
4243
limit: 10,
4344
});
4445

@@ -50,6 +51,7 @@ for (const obj of searchResponse.searchResults.objects) {
5051

5152
// START DiversityRanking
5253
const diversitySearchResponse = await qa.search("summer shoes", {
54+
filtering: "recall",
5355
limit: 10,
5456
diversityWeight: 0.5,
5557
collections: [{
@@ -67,6 +69,7 @@ for (const obj of diversitySearchResponse.searchResults.objects) {
6769
// Search with pagination
6870
const responsePage1 = await qa.search(
6971
"Find summer shoes and accessories between $50 and $100 that have the tag 'sale'", {
72+
filtering: "recall",
7073
limit: 3,
7174
});
7275

docs/query-agent/_includes/code/search_mode.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
# START BasicSearchMode
4242
search_response = qa.search(
4343
query="Find me some vintage shoes under $70",
44+
filtering="recall",
4445
limit=10,
4546
)
4647

@@ -62,6 +63,7 @@
6263

6364
search_response = qa.search(
6465
"summer shoes",
66+
filtering="recall",
6567
limit=10,
6668
diversity_weight=0.5,
6769
)
@@ -74,6 +76,7 @@
7476
# Search with pagination
7577
response_page_1 = qa.search(
7678
"Find summer shoes and accessories between $50 and $100 that have the tag 'sale'",
79+
filtering="recall",
7780
limit=3,
7881
)
7982

@@ -135,6 +138,7 @@
135138
# START AsyncSearch
136139
await async_qa.search(
137140
query="Find me some vintage shoes under $70",
141+
filtering="recall",
138142
limit=10,
139143
)
140144
# END AsyncSearch
@@ -161,6 +165,7 @@ async def _async_run_for_testing():
161165

162166
await async_qa.search(
163167
query="Find me some vintage shoes under $70",
168+
filtering="recall",
164169
limit=10,
165170
)
166171
await async_client.close()

docs/query-agent/guides/search_mode.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ The `.search()` method accepts several arguments:
6767
| `query` | `str \| list[ChatMessage]` | The user query you want the agent to search with. This can be a simple string (`"Find me some vintage shoes under $70"`) or a list of chat messages (for conversational context). [See the page on multi-turn conversations for more detail](../reference/multi_turn_conversations.md). |
6868
| `collections` | `list[str \| QueryAgentCollectionConfig] \| None` | The name(s) of the collections to search. You can pass one or many collection names as a list of strings (e.g., `["ECommerce", "BookSales"]`), or provide collection configuration objects for more control. If specified in the `ask` method, it will overwrite those defined in the instantiation of `QueryAgent`. [See the page on collection configuration for more detail](../reference/advanced_collections.md). |
6969
| `limit` | `int` | The maximum number of results returned in this page of results. Defaults to `20`. Use [`.next()`](#pagination) to fetch additional pages. |
70-
| `filtering` | `Literal["recall", "precision"]` | Either `"recall"` or `"precision"` to control filter generation. `"recall"` favors more results across filter interpretations; `"precision"` favors strict intent match. See [Customized filtering](#customized-filtering) below. |
70+
| `filtering` | `Literal["recall", "precision"]` | **Required.** Either `"recall"` or `"precision"` to control filter generation. `"recall"` favors more results across filter interpretations; `"precision"` favors strict intent match. Pass `"recall"` for most cases. See [Customized filtering](#customized-filtering) below. |
7171
| `diversity_weight` | `float \| None` | A value between `0.0` and `1.0` that biases the result ranking towards diversity using Maximal Marginal Relevance (MMR). See [Diversity ranking](#diversity-ranking) below. |
7272

7373
</TabItem>
@@ -77,7 +77,7 @@ The `.search()` method accepts several arguments:
7777
| `query` | `string \| ChatMessage[]` | The user query you want the agent to search with. This can be a simple string (`"Find me some vintage shoes under $70"`) or a list of chat messages (for conversational context). [See the page on multi-turn conversations for more detail](../reference/multi_turn_conversations.md). |
7878
| `collections` | `(string \| QueryAgentCollectionConfig)[]` | The name(s) of the collections to search. You can pass one or many collection names as a list of strings (e.g., `["ECommerce", "BookSales"]`), or provide collection configuration objects for more control. If specified in the `ask` method, it will overwrite those defined in the instantiation of `QueryAgent`. [See the page on collection configuration for more detail](../reference/advanced_collections.md). |
7979
| `limit` | `number` | The maximum number of results returned in this page of results. Defaults to `20`. Use [`.next()`](#pagination) to fetch additional pages. |
80-
| `filtering` | `"recall" \| "precision"` | Either `"recall"` or `"precision"` to control filter generation. `"recall"` favors more results across filter interpretations; `"precision"` favors strict intent match. See [Customized filtering](#customized-filtering) below. |
80+
| `filtering` | `"recall" \| "precision"` | **Required.** Either `"recall"` or `"precision"` to control filter generation. `"recall"` favors more results across filter interpretations; `"precision"` favors strict intent match. Pass `"recall"` for most cases. See [Customized filtering](#customized-filtering) below. |
8181
| `diversityWeight` | `number` | A value between `0.0` and `1.0` that biases the result ranking towards diversity using Maximal Marginal Relevance (MMR). See [Diversity ranking](#diversity-ranking) below. |
8282

8383
</TabItem>
@@ -89,7 +89,9 @@ For more advanced searches, you can also specify _additional filters_ within the
8989

9090
Search Mode uses query rewriting to transform your original query into one or multiple Weaviate queries, each with either a search query, metadata filters, or both. The `filtering` parameter controls how many Weaviate queries are generated.
9191

92-
- **`"recall"`** (default): Generates multiple Weaviate queries spanning different filters and interpretations of the user query. You should use these when you prefer to get results, even if they don't match every criteria in your query.
92+
`filtering` is a required argument; pass either `"recall"` or `"precision"`. `"recall"` is recommended when you want more results.
93+
94+
- **`"recall"`** (recommended): Generates multiple Weaviate queries spanning different filters and interpretations of the user query. You should use these when you prefer to get results, even if they don't match every criteria in your query.
9395

9496
- **`"precision"`**: Generates a single Weaviate query targeting the most likely interpretation of the user query. You should use this when you want the results to follow your query intent closely, even if that means potentially receiving no results.
9597

0 commit comments

Comments
 (0)