SimpleMongoReader#

class llama_index.readers.SimpleMongoReader(host: Optional[str] = None, port: Optional[int] = None, uri: Optional[str] = None)#

Bases: BaseReader

Simple mongo reader.

Concatenates each Mongo doc into Document used by LlamaIndex.

Parameters
  • host (str) โ€“ Mongo host.

  • port (int) โ€“ Mongo port.

Methods Summary

lazy_load_data(db_name, collection_name[, ...])

Load data from the input directory.

Methods Documentation

lazy_load_data(db_name: str, collection_name: str, field_names: List[str] = ['text'], separator: str = '', query_dict: Optional[Dict] = None, max_docs: int = 0, metadata_names: Optional[List[str]] = None) Iterable[Document]#

Load data from the input directory.

Parameters
  • db_name (str) โ€“ name of the database.

  • collection_name (str) โ€“ name of the collection.

  • field_names (List[str]) โ€“ names of the fields to be concatenated. Defaults to [โ€œtextโ€]

  • separator (str) โ€“ separator to be used between fields. Defaults to โ€œโ€

  • query_dict (Optional[Dict]) โ€“ query to filter documents. Read more

  • docs](https (at [official) โ€“ //www.mongodb.com/docs/manual/reference/method/db.collection.find/#std-label-method-find-query) Defaults to None

  • max_docs (int) โ€“ maximum number of documents to load. Defaults to 0 (no limit)

  • metadata_names (Optional[List[str]]) โ€“ names of the fields to be added to the metadata attribute of the Document. Defaults to None

Returns

A list of documents.

Return type

List[Document]