Skip to content

Commit 554267b

Browse files
HaystackBotanakin87
authored andcommitted
Sync Core Integrations API reference (opensearch) on Docusaurus (#10558)
Co-authored-by: anakin87 <44616784+anakin87@users.noreply.github.com>
1 parent ac60e49 commit 554267b

8 files changed

Lines changed: 456 additions & 120 deletions

File tree

docs-website/reference/integrations-api/opensearch.md

Lines changed: 57 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,8 @@ def __init__(*,
265265
filter_policy: str | FilterPolicy = FilterPolicy.REPLACE,
266266
custom_query: dict[str, Any] | None = None,
267267
raise_on_failure: bool = True,
268-
efficient_filtering: bool = False)
268+
efficient_filtering: bool = False,
269+
search_kwargs: dict[str, Any] | None = None)
269270
```
270271

271272
Create the OpenSearchEmbeddingRetriever component.
@@ -323,6 +324,18 @@ retriever.run(
323324
If `False`, logs a warning and returns an empty list.
324325
- `efficient_filtering`: If `True`, the filter will be applied during the approximate kNN search.
325326
This is only supported for knn engines "faiss" and "lucene" and does not work with the default "nmslib".
327+
- `search_kwargs`: Additional keyword arguments for finetuning the embedding search.
328+
E.g., to specify `k` and `ef_search`
329+
```python
330+
{
331+
"k": 20, # See https://docs.opensearch.org/latest/vector-search/vector-search-techniques/approximate-knn/`the`-number-of-returned-results
332+
"method_parameters": {
333+
"ef_search": 512, # See https://docs.opensearch.org/latest/query-dsl/specialized/k-nn/index/`ef_search`
334+
}
335+
}
336+
```
337+
For a full list of available parameters, see the OpenSearch documentation:
338+
https://docs.opensearch.org/latest/query-dsl/specialized/k-nn/index/`request`-body-fields
326339

327340
**Raises**:
328341

@@ -367,14 +380,14 @@ Deserialized component.
367380

368381
```python
369382
@component.output_types(documents=list[Document])
370-
def run(
371-
query_embedding: list[float],
372-
filters: dict[str, Any] | None = None,
373-
top_k: int | None = None,
374-
custom_query: dict[str, Any] | None = None,
375-
efficient_filtering: bool | None = None,
376-
document_store: OpenSearchDocumentStore | None = None
377-
) -> dict[str, list[Document]]
383+
def run(query_embedding: list[float],
384+
filters: dict[str, Any] | None = None,
385+
top_k: int | None = None,
386+
custom_query: dict[str, Any] | None = None,
387+
efficient_filtering: bool | None = None,
388+
document_store: OpenSearchDocumentStore | None = None,
389+
search_kwargs: dict[str, Any] | None = None
390+
) -> dict[str, list[Document]]
378391
```
379392

380393
Retrieve documents using a vector similarity metric.
@@ -429,6 +442,19 @@ retriever.run(
429442
- `efficient_filtering`: If `True`, the filter will be applied during the approximate kNN search.
430443
This is only supported for knn engines "faiss" and "lucene" and does not work with the default "nmslib".
431444
- `document_store`: Optional instance of OpenSearchDocumentStore to use with the Retriever.
445+
- `search_kwargs`: Additional keyword arguments for finetuning the embedding search. If not provided,
446+
defaults to the parameter set at initialization (if any).
447+
E.g., to specify `k` and `ef_search`
448+
```python
449+
{
450+
"k": 20, # See https://docs.opensearch.org/latest/vector-search/vector-search-techniques/approximate-knn/`the`-number-of-returned-results
451+
"method_parameters": {
452+
"ef_search": 512, # See https://docs.opensearch.org/latest/query-dsl/specialized/k-nn/index/`ef_search`
453+
}
454+
}
455+
```
456+
For a full list of available parameters, see the OpenSearch documentation:
457+
https://docs.opensearch.org/latest/query-dsl/specialized/k-nn/index/`request`-body-fields
432458

433459
**Returns**:
434460

@@ -442,12 +468,13 @@ Dictionary with key "documents" containing the retrieved Documents.
442468
```python
443469
@component.output_types(documents=list[Document])
444470
async def run_async(
445-
query_embedding: list[float],
446-
filters: dict[str, Any] | None = None,
447-
top_k: int | None = None,
448-
custom_query: dict[str, Any] | None = None,
449-
efficient_filtering: bool | None = None,
450-
document_store: OpenSearchDocumentStore | None = None
471+
query_embedding: list[float],
472+
filters: dict[str, Any] | None = None,
473+
top_k: int | None = None,
474+
custom_query: dict[str, Any] | None = None,
475+
efficient_filtering: bool | None = None,
476+
document_store: OpenSearchDocumentStore | None = None,
477+
search_kwargs: dict[str, Any] | None = None
451478
) -> dict[str, list[Document]]
452479
```
453480

@@ -503,6 +530,19 @@ retriever.run(
503530
- `efficient_filtering`: If `True`, the filter will be applied during the approximate kNN search.
504531
This is only supported for knn engines "faiss" and "lucene" and does not work with the default "nmslib".
505532
- `document_store`: Optional instance of OpenSearchDocumentStore to use with the Retriever.
533+
- `search_kwargs`: Additional keyword arguments for finetuning the embedding search. If not provided,
534+
defaults to the parameter set at initialization (if any).
535+
E.g., to specify `k` and `ef_search`
536+
```python
537+
{
538+
"k": 20, # See https://docs.opensearch.org/latest/vector-search/vector-search-techniques/approximate-knn/`the`-number-of-returned-results
539+
"method_parameters": {
540+
"ef_search": 512, # See https://docs.opensearch.org/latest/query-dsl/specialized/k-nn/index/`ef_search`
541+
}
542+
}
543+
```
544+
For a full list of available parameters, see the OpenSearch documentation:
545+
https://docs.opensearch.org/latest/query-dsl/specialized/k-nn/index/`request`-body-fields
506546

507547
**Returns**:
508548

@@ -911,6 +951,7 @@ def __init__(document_store: OpenSearchDocumentStore,
911951
filter_policy_embedding: str
912952
| FilterPolicy = FilterPolicy.REPLACE,
913953
custom_query_embedding: dict[str, Any] | None = None,
954+
search_kwargs_embedding: dict[str, Any] | None = None,
914955
join_mode: str | JoinMode = JoinMode.RECIPROCAL_RANK_FUSION,
915956
weights: list[float] | None = None,
916957
top_k: int | None = None,
@@ -948,6 +989,7 @@ See `haystack.components.embedders.types.protocol.TextEmbedder` for more informa
948989
- `top_k_embedding`: The number of results to return from the embedding retriever.
949990
- `filter_policy_embedding`: The filter policy for the embedding retriever.
950991
- `custom_query_embedding`: A custom query for the embedding retriever.
992+
- `search_kwargs_embedding`: Additional search kwargs for the embedding retriever.
951993
- `join_mode`: The mode to use for joining the results from the BM25 and embedding retrievers.
952994
- `weights`: The weights for the joiner.
953995
- `top_k`: The number of results to return from the joiner.

docs-website/reference_versioned_docs/version-2.18/integrations-api/opensearch.md

Lines changed: 57 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,8 @@ def __init__(*,
265265
filter_policy: str | FilterPolicy = FilterPolicy.REPLACE,
266266
custom_query: dict[str, Any] | None = None,
267267
raise_on_failure: bool = True,
268-
efficient_filtering: bool = False)
268+
efficient_filtering: bool = False,
269+
search_kwargs: dict[str, Any] | None = None)
269270
```
270271

271272
Create the OpenSearchEmbeddingRetriever component.
@@ -323,6 +324,18 @@ retriever.run(
323324
If `False`, logs a warning and returns an empty list.
324325
- `efficient_filtering`: If `True`, the filter will be applied during the approximate kNN search.
325326
This is only supported for knn engines "faiss" and "lucene" and does not work with the default "nmslib".
327+
- `search_kwargs`: Additional keyword arguments for finetuning the embedding search.
328+
E.g., to specify `k` and `ef_search`
329+
```python
330+
{
331+
"k": 20, # See https://docs.opensearch.org/latest/vector-search/vector-search-techniques/approximate-knn/`the`-number-of-returned-results
332+
"method_parameters": {
333+
"ef_search": 512, # See https://docs.opensearch.org/latest/query-dsl/specialized/k-nn/index/`ef_search`
334+
}
335+
}
336+
```
337+
For a full list of available parameters, see the OpenSearch documentation:
338+
https://docs.opensearch.org/latest/query-dsl/specialized/k-nn/index/`request`-body-fields
326339

327340
**Raises**:
328341

@@ -367,14 +380,14 @@ Deserialized component.
367380

368381
```python
369382
@component.output_types(documents=list[Document])
370-
def run(
371-
query_embedding: list[float],
372-
filters: dict[str, Any] | None = None,
373-
top_k: int | None = None,
374-
custom_query: dict[str, Any] | None = None,
375-
efficient_filtering: bool | None = None,
376-
document_store: OpenSearchDocumentStore | None = None
377-
) -> dict[str, list[Document]]
383+
def run(query_embedding: list[float],
384+
filters: dict[str, Any] | None = None,
385+
top_k: int | None = None,
386+
custom_query: dict[str, Any] | None = None,
387+
efficient_filtering: bool | None = None,
388+
document_store: OpenSearchDocumentStore | None = None,
389+
search_kwargs: dict[str, Any] | None = None
390+
) -> dict[str, list[Document]]
378391
```
379392

380393
Retrieve documents using a vector similarity metric.
@@ -429,6 +442,19 @@ retriever.run(
429442
- `efficient_filtering`: If `True`, the filter will be applied during the approximate kNN search.
430443
This is only supported for knn engines "faiss" and "lucene" and does not work with the default "nmslib".
431444
- `document_store`: Optional instance of OpenSearchDocumentStore to use with the Retriever.
445+
- `search_kwargs`: Additional keyword arguments for finetuning the embedding search. If not provided,
446+
defaults to the parameter set at initialization (if any).
447+
E.g., to specify `k` and `ef_search`
448+
```python
449+
{
450+
"k": 20, # See https://docs.opensearch.org/latest/vector-search/vector-search-techniques/approximate-knn/`the`-number-of-returned-results
451+
"method_parameters": {
452+
"ef_search": 512, # See https://docs.opensearch.org/latest/query-dsl/specialized/k-nn/index/`ef_search`
453+
}
454+
}
455+
```
456+
For a full list of available parameters, see the OpenSearch documentation:
457+
https://docs.opensearch.org/latest/query-dsl/specialized/k-nn/index/`request`-body-fields
432458

433459
**Returns**:
434460

@@ -442,12 +468,13 @@ Dictionary with key "documents" containing the retrieved Documents.
442468
```python
443469
@component.output_types(documents=list[Document])
444470
async def run_async(
445-
query_embedding: list[float],
446-
filters: dict[str, Any] | None = None,
447-
top_k: int | None = None,
448-
custom_query: dict[str, Any] | None = None,
449-
efficient_filtering: bool | None = None,
450-
document_store: OpenSearchDocumentStore | None = None
471+
query_embedding: list[float],
472+
filters: dict[str, Any] | None = None,
473+
top_k: int | None = None,
474+
custom_query: dict[str, Any] | None = None,
475+
efficient_filtering: bool | None = None,
476+
document_store: OpenSearchDocumentStore | None = None,
477+
search_kwargs: dict[str, Any] | None = None
451478
) -> dict[str, list[Document]]
452479
```
453480

@@ -503,6 +530,19 @@ retriever.run(
503530
- `efficient_filtering`: If `True`, the filter will be applied during the approximate kNN search.
504531
This is only supported for knn engines "faiss" and "lucene" and does not work with the default "nmslib".
505532
- `document_store`: Optional instance of OpenSearchDocumentStore to use with the Retriever.
533+
- `search_kwargs`: Additional keyword arguments for finetuning the embedding search. If not provided,
534+
defaults to the parameter set at initialization (if any).
535+
E.g., to specify `k` and `ef_search`
536+
```python
537+
{
538+
"k": 20, # See https://docs.opensearch.org/latest/vector-search/vector-search-techniques/approximate-knn/`the`-number-of-returned-results
539+
"method_parameters": {
540+
"ef_search": 512, # See https://docs.opensearch.org/latest/query-dsl/specialized/k-nn/index/`ef_search`
541+
}
542+
}
543+
```
544+
For a full list of available parameters, see the OpenSearch documentation:
545+
https://docs.opensearch.org/latest/query-dsl/specialized/k-nn/index/`request`-body-fields
506546

507547
**Returns**:
508548

@@ -911,6 +951,7 @@ def __init__(document_store: OpenSearchDocumentStore,
911951
filter_policy_embedding: str
912952
| FilterPolicy = FilterPolicy.REPLACE,
913953
custom_query_embedding: dict[str, Any] | None = None,
954+
search_kwargs_embedding: dict[str, Any] | None = None,
914955
join_mode: str | JoinMode = JoinMode.RECIPROCAL_RANK_FUSION,
915956
weights: list[float] | None = None,
916957
top_k: int | None = None,
@@ -948,6 +989,7 @@ See `haystack.components.embedders.types.protocol.TextEmbedder` for more informa
948989
- `top_k_embedding`: The number of results to return from the embedding retriever.
949990
- `filter_policy_embedding`: The filter policy for the embedding retriever.
950991
- `custom_query_embedding`: A custom query for the embedding retriever.
992+
- `search_kwargs_embedding`: Additional search kwargs for the embedding retriever.
951993
- `join_mode`: The mode to use for joining the results from the BM25 and embedding retrievers.
952994
- `weights`: The weights for the joiner.
953995
- `top_k`: The number of results to return from the joiner.

docs-website/reference_versioned_docs/version-2.19/integrations-api/opensearch.md

Lines changed: 57 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,8 @@ def __init__(*,
265265
filter_policy: str | FilterPolicy = FilterPolicy.REPLACE,
266266
custom_query: dict[str, Any] | None = None,
267267
raise_on_failure: bool = True,
268-
efficient_filtering: bool = False)
268+
efficient_filtering: bool = False,
269+
search_kwargs: dict[str, Any] | None = None)
269270
```
270271

271272
Create the OpenSearchEmbeddingRetriever component.
@@ -323,6 +324,18 @@ retriever.run(
323324
If `False`, logs a warning and returns an empty list.
324325
- `efficient_filtering`: If `True`, the filter will be applied during the approximate kNN search.
325326
This is only supported for knn engines "faiss" and "lucene" and does not work with the default "nmslib".
327+
- `search_kwargs`: Additional keyword arguments for finetuning the embedding search.
328+
E.g., to specify `k` and `ef_search`
329+
```python
330+
{
331+
"k": 20, # See https://docs.opensearch.org/latest/vector-search/vector-search-techniques/approximate-knn/`the`-number-of-returned-results
332+
"method_parameters": {
333+
"ef_search": 512, # See https://docs.opensearch.org/latest/query-dsl/specialized/k-nn/index/`ef_search`
334+
}
335+
}
336+
```
337+
For a full list of available parameters, see the OpenSearch documentation:
338+
https://docs.opensearch.org/latest/query-dsl/specialized/k-nn/index/`request`-body-fields
326339

327340
**Raises**:
328341

@@ -367,14 +380,14 @@ Deserialized component.
367380

368381
```python
369382
@component.output_types(documents=list[Document])
370-
def run(
371-
query_embedding: list[float],
372-
filters: dict[str, Any] | None = None,
373-
top_k: int | None = None,
374-
custom_query: dict[str, Any] | None = None,
375-
efficient_filtering: bool | None = None,
376-
document_store: OpenSearchDocumentStore | None = None
377-
) -> dict[str, list[Document]]
383+
def run(query_embedding: list[float],
384+
filters: dict[str, Any] | None = None,
385+
top_k: int | None = None,
386+
custom_query: dict[str, Any] | None = None,
387+
efficient_filtering: bool | None = None,
388+
document_store: OpenSearchDocumentStore | None = None,
389+
search_kwargs: dict[str, Any] | None = None
390+
) -> dict[str, list[Document]]
378391
```
379392

380393
Retrieve documents using a vector similarity metric.
@@ -429,6 +442,19 @@ retriever.run(
429442
- `efficient_filtering`: If `True`, the filter will be applied during the approximate kNN search.
430443
This is only supported for knn engines "faiss" and "lucene" and does not work with the default "nmslib".
431444
- `document_store`: Optional instance of OpenSearchDocumentStore to use with the Retriever.
445+
- `search_kwargs`: Additional keyword arguments for finetuning the embedding search. If not provided,
446+
defaults to the parameter set at initialization (if any).
447+
E.g., to specify `k` and `ef_search`
448+
```python
449+
{
450+
"k": 20, # See https://docs.opensearch.org/latest/vector-search/vector-search-techniques/approximate-knn/`the`-number-of-returned-results
451+
"method_parameters": {
452+
"ef_search": 512, # See https://docs.opensearch.org/latest/query-dsl/specialized/k-nn/index/`ef_search`
453+
}
454+
}
455+
```
456+
For a full list of available parameters, see the OpenSearch documentation:
457+
https://docs.opensearch.org/latest/query-dsl/specialized/k-nn/index/`request`-body-fields
432458

433459
**Returns**:
434460

@@ -442,12 +468,13 @@ Dictionary with key "documents" containing the retrieved Documents.
442468
```python
443469
@component.output_types(documents=list[Document])
444470
async def run_async(
445-
query_embedding: list[float],
446-
filters: dict[str, Any] | None = None,
447-
top_k: int | None = None,
448-
custom_query: dict[str, Any] | None = None,
449-
efficient_filtering: bool | None = None,
450-
document_store: OpenSearchDocumentStore | None = None
471+
query_embedding: list[float],
472+
filters: dict[str, Any] | None = None,
473+
top_k: int | None = None,
474+
custom_query: dict[str, Any] | None = None,
475+
efficient_filtering: bool | None = None,
476+
document_store: OpenSearchDocumentStore | None = None,
477+
search_kwargs: dict[str, Any] | None = None
451478
) -> dict[str, list[Document]]
452479
```
453480

@@ -503,6 +530,19 @@ retriever.run(
503530
- `efficient_filtering`: If `True`, the filter will be applied during the approximate kNN search.
504531
This is only supported for knn engines "faiss" and "lucene" and does not work with the default "nmslib".
505532
- `document_store`: Optional instance of OpenSearchDocumentStore to use with the Retriever.
533+
- `search_kwargs`: Additional keyword arguments for finetuning the embedding search. If not provided,
534+
defaults to the parameter set at initialization (if any).
535+
E.g., to specify `k` and `ef_search`
536+
```python
537+
{
538+
"k": 20, # See https://docs.opensearch.org/latest/vector-search/vector-search-techniques/approximate-knn/`the`-number-of-returned-results
539+
"method_parameters": {
540+
"ef_search": 512, # See https://docs.opensearch.org/latest/query-dsl/specialized/k-nn/index/`ef_search`
541+
}
542+
}
543+
```
544+
For a full list of available parameters, see the OpenSearch documentation:
545+
https://docs.opensearch.org/latest/query-dsl/specialized/k-nn/index/`request`-body-fields
506546

507547
**Returns**:
508548

@@ -911,6 +951,7 @@ def __init__(document_store: OpenSearchDocumentStore,
911951
filter_policy_embedding: str
912952
| FilterPolicy = FilterPolicy.REPLACE,
913953
custom_query_embedding: dict[str, Any] | None = None,
954+
search_kwargs_embedding: dict[str, Any] | None = None,
914955
join_mode: str | JoinMode = JoinMode.RECIPROCAL_RANK_FUSION,
915956
weights: list[float] | None = None,
916957
top_k: int | None = None,
@@ -948,6 +989,7 @@ See `haystack.components.embedders.types.protocol.TextEmbedder` for more informa
948989
- `top_k_embedding`: The number of results to return from the embedding retriever.
949990
- `filter_policy_embedding`: The filter policy for the embedding retriever.
950991
- `custom_query_embedding`: A custom query for the embedding retriever.
992+
- `search_kwargs_embedding`: Additional search kwargs for the embedding retriever.
951993
- `join_mode`: The mode to use for joining the results from the BM25 and embedding retrievers.
952994
- `weights`: The weights for the joiner.
953995
- `top_k`: The number of results to return from the joiner.

0 commit comments

Comments
 (0)