Skip to content

Mongodb

MongoIndexStore #

Bases: KVIndexStore

Mongo Index store.

Parameters:

Name Type Description Default
mongo_kvstore MongoDBKVStore

MongoDB key-value store

required
namespace str

namespace for the index store

None
Source code in llama-index-integrations/storage/index_store/llama-index-storage-index-store-mongodb/llama_index/storage/index_store/mongodb/base.py
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
class MongoIndexStore(KVIndexStore):
    """Mongo Index store.

    Args:
        mongo_kvstore (MongoDBKVStore): MongoDB key-value store
        namespace (str): namespace for the index store

    """

    def __init__(
        self,
        mongo_kvstore: MongoDBKVStore,
        namespace: Optional[str] = None,
    ) -> None:
        """Init a MongoIndexStore."""
        super().__init__(mongo_kvstore, namespace=namespace)

    @classmethod
    def from_uri(
        cls,
        uri: str,
        db_name: Optional[str] = None,
        namespace: Optional[str] = None,
    ) -> "MongoIndexStore":
        """Load a MongoIndexStore from a MongoDB URI."""
        mongo_kvstore = MongoDBKVStore.from_uri(uri, db_name)
        return cls(mongo_kvstore, namespace)

    @classmethod
    def from_host_and_port(
        cls,
        host: str,
        port: int,
        db_name: Optional[str] = None,
        namespace: Optional[str] = None,
    ) -> "MongoIndexStore":
        """Load a MongoIndexStore from a MongoDB host and port."""
        mongo_kvstore = MongoDBKVStore.from_host_and_port(host, port, db_name)
        return cls(mongo_kvstore, namespace)

from_uri classmethod #

from_uri(uri: str, db_name: Optional[str] = None, namespace: Optional[str] = None) -> MongoIndexStore

Load a MongoIndexStore from a MongoDB URI.

Source code in llama-index-integrations/storage/index_store/llama-index-storage-index-store-mongodb/llama_index/storage/index_store/mongodb/base.py
24
25
26
27
28
29
30
31
32
33
@classmethod
def from_uri(
    cls,
    uri: str,
    db_name: Optional[str] = None,
    namespace: Optional[str] = None,
) -> "MongoIndexStore":
    """Load a MongoIndexStore from a MongoDB URI."""
    mongo_kvstore = MongoDBKVStore.from_uri(uri, db_name)
    return cls(mongo_kvstore, namespace)

from_host_and_port classmethod #

from_host_and_port(host: str, port: int, db_name: Optional[str] = None, namespace: Optional[str] = None) -> MongoIndexStore

Load a MongoIndexStore from a MongoDB host and port.

Source code in llama-index-integrations/storage/index_store/llama-index-storage-index-store-mongodb/llama_index/storage/index_store/mongodb/base.py
35
36
37
38
39
40
41
42
43
44
45
@classmethod
def from_host_and_port(
    cls,
    host: str,
    port: int,
    db_name: Optional[str] = None,
    namespace: Optional[str] = None,
) -> "MongoIndexStore":
    """Load a MongoIndexStore from a MongoDB host and port."""
    mongo_kvstore = MongoDBKVStore.from_host_and_port(host, port, db_name)
    return cls(mongo_kvstore, namespace)