MongoDBAtlasFullTextRetriever
Retrieve documents from the MongoDBAtlasDocumentStore by full-text search. This retriever is only compatible with the MongoDBAtlasDocumentStore.
Basic Information
- Type:
haystack_integrations.mongodb_atlas.src.haystack_integrations.components.retrievers.mongodb_atlas.full_text_retriever.MongoDBAtlasFullTextRetriever - Components it can connect with:
Input:MongoDBAtlasFullTextRetrievercan receive the query from theInputcomponent.Rankers:MongoDBAtlasFullTextRetrievercan send the retrieved documents to a Ranker.
Inputs
| Parameter | Type | Default | Description |
|---|---|---|---|
| query | Union[str, List[str]] | The query string or a list of query strings to search for. If the query contains multiple terms, Atlas Search evaluates each term separately for matches. | |
| fuzzy | Optional[Dict[str, int]] | None | Enables finding strings similar to the search terms. Note that you can't use fuzzy with synonyms. Configurable options include maxEdits, prefixLength, and maxExpansions. For more details refer to MongoDB Atlas documentation. |
| match_criteria | Optional[Literal['any', 'all']] | None | Defines how terms in the query are matched. Supported options are "any" and "all". For more details refer to MongoDB Atlas documentation. |
| score | Optional[Dict[str, Dict]] | None | Specifies the scoring method for matching results. Supported options include boost, constant, and function. For more details refer to MongoDB Atlas documentation. |
| synonyms | Optional[str] | None | The name of the synonym mapping definition in the index. This value cannot be an empty string. Note that you can't use synonyms with fuzzy. |
| filters | Optional[Dict[str, Any]] | None | Filters applied to the retrieved Documents. The way runtime filters are applied depends on the filter_policy configured for the retriever. For details, see the Init Parameters section below. |
| top_k | int | 10 | Maximum number of Documents to return. |
Outputs
| Parameter | Type | Default | Description |
|---|---|---|---|
| documents | List[Document] | ist of Documents most similar to the given query. |
Overview
Use MongoDBAtlasFullTextRetriever to retrieve documents from the MongoDBAtlasDocumentStore by full-text search. This retriever is only compatible with the MongoDBAtlasDocumentStore.
The full text search depends on the full_text_search_index used in the MongoDBAtlasDocumentStore.
Usage Example
This is a query pipeline with MongoDBAtlasFullTextRetriever that searches for documents in the MongoDBAtlasDocumentStore.
components:
TransformersSimilarityRanker:
type: haystack.components.rankers.transformers_similarity.TransformersSimilarityRanker
init_parameters:
model: cross-encoder/ms-marco-MiniLM-L-6-v2
device:
token:
type: env_var
env_vars:
- HF_API_TOKEN
- HF_TOKEN
strict: false
top_k: 10
query_prefix: ''
document_prefix: ''
meta_fields_to_embed:
embedding_separator: \n
scale_score: true
calibration_factor: 1
score_threshold:
model_kwargs:
tokenizer_kwargs:
batch_size: 16
MongoDBAtlasFullTextRetriever:
type: haystack_integrations.components.retrievers.mongodb_atlas.full_text_retriever.MongoDBAtlasFullTextRetriever
init_parameters:
filters:
top_k: 10
filter_policy: replace
document_store:
type: haystack_integrations.document_stores.mongodb_atlas.document_store.MongoDBAtlasDocumentStore
init_parameters:
mongo_connection_string:
type: env_var
env_vars:
- MONGO_CONNECTION_STRING
strict: false
database_name: my-db
collection_name: my-collection
vector_search_index: vector-search
full_text_search_index: full-text-search
embedding_field: embedding
content_field: content
connections:
- sender: MongoDBAtlasFullTextRetriever.documents
receiver: TransformersSimilarityRanker.documents
max_runs_per_component: 100
metadata: {}
inputs:
query:
- TransformersSimilarityRanker.query
- MongoDBAtlasFullTextRetriever.query
outputs:
documents: TransformersSimilarityRanker.documents
Parameters
Init Parameters
These are the parameters you can configure in Pipeline Builder:
| Parameter | Type | Default | Description |
|---|---|---|---|
| document_store | MongoDBAtlasDocumentStore | An instance of MongoDBAtlasDocumentStore. | |
| filters | Optional[Dict[str, Any]] | None | Filters applied to the retrieved Documents. Make sure that the fields used in the filters are included in the configuration of the full_text_search_index. The configuration must be done manually in the Web UI of MongoDB Atlas. |
| top_k | int | 10 | Maximum number of Documents to return. |
| filter_policy | Union[str, FilterPolicy] | FilterPolicy.REPLACE | Policy to determine how filters are applied if they're configured for the component but also passed at runtime. Possible values: MERGE and REPLACE. MERGE: If both filter types target the same field, the runtime filter takes precedence. Logical filters are combined unly if they have the same operator (AND, OR). Comparison filters are combined using the default logical operator (defaults to AND). |
Run Method Parameters
These are the parameters you can configure for the component's run() method. This means you can pass these parameters at query time through the API, in Playground, or when running a job. For details, see Modify Pipeline Parameters at Query Time.
| Parameter | Type | Default | Description |
|---|---|---|---|
| query | Union[str, List[str]] | The query string or a list of query strings to search for. If the query contains multiple terms, Atlas Search evaluates each term separately for matches. | |
| fuzzy | Optional[Dict[str, int]] | None | Enables finding strings similar to the search terms. Note that you can't use fuzzy with synonyms. Configurable options include maxEdits, prefixLength, and maxExpansions. For more details refer to MongoDB Atlas documentation. |
| match_criteria | Optional[Literal['any', 'all']] | None | Defines how terms in the query are matched. Supported options are "any" and "all". For more details refer to MongoDB Atlas documentation. |
| score | Optional[Dict[str, Dict]] | None | Specifies the scoring method for matching results. Supported options include boost, constant, and function. For more details refer to MongoDB Atlas documentation. |
| synonyms | Optional[str] | None | The name of the synonym mapping definition in the index. This value cannot be an empty string. Note that you can't use synonyms with fuzzy. |
| filters | Optional[Dict[str, Any]] | None | Filters applied to the retrieved Documents. The way runtime filters are applied depends on the filter_policy configured for the retriever. |
| top_k | int | 10 | Maximum number of Documents to return. |
Was this page helpful?