MongoDBAtlasFullTextRetriever
Retrieves documents from the MongoDBAtlasDocumentStore by full-text search.
Basic Information
- Type:
haystack_integrations.mongodb_atlas.src.haystack_integrations.components.retrievers.mongodb_atlas.full_text_retriever.MongoDBAtlasFullTextRetriever
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 term(s). Note, fuzzy cannot be used 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, synonyms can not be used 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 chosen at retriever initialization. See init method docstring for more details. |
| top_k | int | 10 | Maximum number of Documents to return. Overrides the value specified at initialization. |
Outputs
| Parameter | Type | Default | Description |
|---|---|---|---|
| documents | List[Document] | A dictionary with the following keys: - documents: List of Documents most similar to the given query |
Overview
Bear with us while we're working on adding pipeline examples and most common components connections.
Retrieves documents from the MongoDBAtlasDocumentStore by full-text search.
The full-text search is dependent on the full_text_search_index used in the MongoDBAtlasDocumentStore. See MongoDBAtlasDocumentStore for more information.
Usage example:
from haystack_integrations.document_stores.mongodb_atlas import MongoDBAtlasDocumentStore
from haystack_integrations.components.retrievers.mongodb_atlas import MongoDBAtlasFullTextRetriever
store = MongoDBAtlasDocumentStore(database_name="your_existing_db",
collection_name="your_existing_collection",
vector_search_index="your_existing_index",
full_text_search_index="your_existing_index")
retriever = MongoDBAtlasFullTextRetriever(document_store=store)
results = retriever.run(query="Lorem ipsum")
print(results["documents"])
The example above retrieves the 10 most similar documents to the query "Lorem ipsum" from the MongoDBAtlasDocumentStore.
Usage Example
components:
MongoDBAtlasFullTextRetriever:
type: mongodb_atlas.src.haystack_integrations.components.retrievers.mongodb_atlas.full_text_retriever.MongoDBAtlasFullTextRetriever
init_parameters:
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. |
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 term(s). Note, fuzzy cannot be used 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, synonyms can not be used 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 chosen at retriever initialization. See init method docstring for more details. |
| top_k | int | 10 | Maximum number of Documents to return. Overrides the value specified at initialization. |
Was this page helpful?