Skip to content

Commit 9e974c4

Browse files
docs: sync Haystack API reference on Docusaurus (#11884)
Co-authored-by: bogdankostic <48713846+bogdankostic@users.noreply.github.com>
1 parent b25f5d8 commit 9e974c4

1 file changed

Lines changed: 24 additions & 4 deletions

File tree

docs-website/reference/haystack-api/retrievers_api.md

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -927,7 +927,8 @@ __init__(
927927
*,
928928
retrievers: dict[str, TextRetriever],
929929
filters: dict[str, Any] | None = None,
930-
top_k: int = 10,
930+
top_k_per_retriever: int | None = None,
931+
top_k: int | None = None,
931932
max_workers: int = 4,
932933
join_mode: Literal[
933934
"concatenate", "reciprocal_rank_fusion"
@@ -942,7 +943,12 @@ Create the MultiRetriever component.
942943
- **retrievers** (<code>dict\[str, TextRetriever\]</code>) – A dictionary mapping names to text retrievers (implementing the `TextRetriever` protocol) to run in
943944
parallel.
944945
- **filters** (<code>dict\[str, Any\] | None</code>) – A dictionary of filters to apply when retrieving documents.
945-
- **top_k** (<code>int</code>) – The maximum number of documents to return per retriever.
946+
- **top_k_per_retriever** (<code>int | None</code>) – The maximum number of documents to return per retriever. If set, this will override the `top_k`
947+
parameter for each retriever. If None, the `top_k` parameter of retrievers will be used.
948+
- **top_k** (<code>int | None</code>) – The maximum number of documents to return overall, extracted from the combined results of all
949+
retrievers. When set, the results are always merged using reciprocal rank fusion (regardless of
950+
`join_mode`) so that the combined list has a consistent global ranking before it is truncated to
951+
`top_k`. If None, all results are returned.
946952
- **max_workers** (<code>int</code>) – The maximum number of threads to use for parallel retrieval.
947953
- **join_mode** (<code>Literal['concatenate', 'reciprocal_rank_fusion']</code>) – How to merge results from multiple retrievers. Available modes:
948954
- `concatenate`: Combines all results into a single list and deduplicates.
@@ -962,6 +968,7 @@ Warm up the retrievers if any has a warm_up method.
962968
run(
963969
query: str,
964970
filters: dict[str, Any] | None = None,
971+
top_k_per_retriever: int | None = None,
965972
top_k: int | None = None,
966973
*,
967974
active_retrievers: list[str] | None = None
@@ -974,7 +981,13 @@ Runs retrievers in parallel on the given query and returns deduplicated results.
974981

975982
- **query** (<code>str</code>) – The query to run the retrievers on.
976983
- **filters** (<code>dict\[str, Any\] | None</code>) – Filters to apply. Defaults to the value set at initialization.
977-
- **top_k** (<code>int | None</code>) – Maximum documents to return per retriever. Defaults to the value set at initialization.
984+
- **top_k_per_retriever** (<code>int | None</code>) – The maximum number of documents to return per retriever. When set, this will override the `top_k`
985+
parameter for each retriever. If None, the `top_k` parameter set for retrievers will be used.
986+
Defaults to the value set at initialization.
987+
- **top_k** (<code>int | None</code>) – The maximum number of documents to return overall, extracted from the combined results of all
988+
retrievers. When set, the results are always merged using reciprocal rank fusion (regardless of
989+
`join_mode`) so that the combined list has a consistent global ranking before it is truncated to
990+
`top_k`. If None, all results are returned. Defaults to the value set at initialization.
978991
- **active_retrievers** (<code>list\[str\] | None</code>) – Names of retrievers to run. Defaults to all. Must match keys in the `retrievers` dictionary.
979992

980993
**Returns:**
@@ -992,6 +1005,7 @@ Runs retrievers in parallel on the given query and returns deduplicated results.
9921005
run_async(
9931006
query: str,
9941007
filters: dict[str, Any] | None = None,
1008+
top_k_per_retriever: int | None = None,
9951009
top_k: int | None = None,
9961010
*,
9971011
active_retrievers: list[str] | None = None
@@ -1006,7 +1020,13 @@ Uses each retriever's `run_async` method if available, otherwise runs `run` in a
10061020

10071021
- **query** (<code>str</code>) – The query to run the retrievers on.
10081022
- **filters** (<code>dict\[str, Any\] | None</code>) – Filters to apply. Defaults to the value set at initialization.
1009-
- **top_k** (<code>int | None</code>) – Maximum documents to return per retriever. Defaults to the value set at initialization.
1023+
- **top_k_per_retriever** (<code>int | None</code>) – The maximum number of documents to return per retriever. When set, this will override the `top_k`
1024+
parameter for each retriever. If None, the `top_k` parameter set for retrievers will be used.
1025+
Defaults to the value set at initialization.
1026+
- **top_k** (<code>int | None</code>) – The maximum number of documents to return overall, extracted from the combined results of all
1027+
retrievers. When set, the results are always merged using reciprocal rank fusion (regardless of
1028+
`join_mode`) so that the combined list has a consistent global ranking before it is truncated to
1029+
`top_k`. If None, all results are returned. Defaults to the value set at initialization.
10101030
- **active_retrievers** (<code>list\[str\] | None</code>) – Names of retrievers to run. Defaults to all. Must match keys in the `retrievers` dictionary.
10111031

10121032
**Returns:**

0 commit comments

Comments
 (0)