Aller au contenu principal

Class: VectorStoreIndex

The VectorStoreIndex, an index that stores the nodes only according to their vector embedings.

Hierarchy

Constructors

constructor

Private new VectorStoreIndex(init)

Parameters

NameType
initVectorIndexConstructorProps

Overrides

BaseIndex.constructor

Defined in

packages/core/src/indices/vectorStore/VectorStoreIndex.ts:64

Properties

docStore

docStore: BaseDocumentStore

Inherited from

BaseIndex.docStore

Defined in

packages/core/src/indices/BaseIndex.ts:156


embedModel

embedModel: BaseEmbedding

Defined in

packages/core/src/indices/vectorStore/VectorStoreIndex.ts:60


imageEmbedModel

Optional imageEmbedModel: MultiModalEmbedding

Defined in

packages/core/src/indices/vectorStore/VectorStoreIndex.ts:62


imageVectorStore

Optional imageVectorStore: VectorStore

Defined in

packages/core/src/indices/vectorStore/VectorStoreIndex.ts:61


indexStore

indexStore: BaseIndexStore

Overrides

BaseIndex.indexStore

Defined in

packages/core/src/indices/vectorStore/VectorStoreIndex.ts:59


indexStruct

indexStruct: IndexDict

Inherited from

BaseIndex.indexStruct

Defined in

packages/core/src/indices/BaseIndex.ts:159


serviceContext

serviceContext: ServiceContext

Inherited from

BaseIndex.serviceContext

Defined in

packages/core/src/indices/BaseIndex.ts:154


storageContext

storageContext: StorageContext

Inherited from

BaseIndex.storageContext

Defined in

packages/core/src/indices/BaseIndex.ts:155


vectorStore

vectorStore: VectorStore

Overrides

BaseIndex.vectorStore

Defined in

packages/core/src/indices/vectorStore/VectorStoreIndex.ts:58

Methods

asQueryEngine

asQueryEngine(options?): BaseQueryEngine

Create a new query engine from the index. It will also create a retriever and response synthezier if they are not provided.

Parameters

NameTypeDescription
options?Objectyou can supply your own custom Retriever and ResponseSynthesizer
options.nodePostprocessors?BaseNodePostprocessor[]-
options.preFilters?unknown-
options.responseSynthesizer?ResponseSynthesizer-
options.retriever?BaseRetriever-

Returns

BaseQueryEngine

Overrides

BaseIndex.asQueryEngine

Defined in

packages/core/src/indices/vectorStore/VectorStoreIndex.ts:244


asRetriever

asRetriever(options?): VectorIndexRetriever

Create a new retriever from the index.

Parameters

NameType
options?any

Returns

VectorIndexRetriever

Overrides

BaseIndex.asRetriever

Defined in

packages/core/src/indices/vectorStore/VectorStoreIndex.ts:240


buildIndexFromNodes

buildIndexFromNodes(nodes): Promise<void>

Get embeddings for nodes and place them into the index.

Parameters

NameType
nodesBaseNode<Metadata>[]

Returns

Promise<void>

Defined in

packages/core/src/indices/vectorStore/VectorStoreIndex.ts:178


deleteRefDoc

deleteRefDoc(refDocId, deleteFromDocStore?): Promise<void>

Parameters

NameTypeDefault value
refDocIdstringundefined
deleteFromDocStorebooleantrue

Returns

Promise<void>

Overrides

BaseIndex.deleteRefDoc

Defined in

packages/core/src/indices/vectorStore/VectorStoreIndex.ts:305


deleteRefDocFromStore

Protected deleteRefDocFromStore(vectorStore, refDocId): Promise<void>

Parameters

NameType
vectorStoreVectorStore
refDocIdstring

Returns

Promise<void>

Defined in

packages/core/src/indices/vectorStore/VectorStoreIndex.ts:319


getImageNodeEmbeddingResults

getImageNodeEmbeddingResults(nodes, logProgress?): Promise<BaseNode<Metadata>[]>

Get the embeddings for image nodes.

Parameters

NameTypeDefault valueDescription
nodesImageNode<Metadata>[]undefined
logProgressbooleanfalselog progress to console (useful for debugging)

Returns

Promise<BaseNode<Metadata>[]>

Defined in

packages/core/src/indices/vectorStore/VectorStoreIndex.ts:345


getNodeEmbeddingResults

getNodeEmbeddingResults(nodes, logProgress?): Promise<BaseNode<Metadata>[]>

Get the embeddings for nodes.

Parameters

NameTypeDefault valueDescription
nodesBaseNode<Metadata>[]undefined
logProgressbooleanfalselog progress to console (useful for debugging)

Returns

Promise<BaseNode<Metadata>[]>

Defined in

packages/core/src/indices/vectorStore/VectorStoreIndex.ts:155


insert

insert(document): Promise<void>

Insert a document into the index.

Parameters

NameType
documentDocument<Metadata>

Returns

Promise<void>

Inherited from

BaseIndex.insert

Defined in

packages/core/src/indices/BaseIndex.ts:190


insertNodes

insertNodes(nodes): Promise<void>

Parameters

NameType
nodesBaseNode<Metadata>[]

Returns

Promise<void>

Overrides

BaseIndex.insertNodes

Defined in

packages/core/src/indices/vectorStore/VectorStoreIndex.ts:284


insertNodesToStore

Protected insertNodesToStore(vectorStore, nodes): Promise<void>

Parameters

NameType
vectorStoreVectorStore
nodesBaseNode<Metadata>[]

Returns

Promise<void>

Defined in

packages/core/src/indices/vectorStore/VectorStoreIndex.ts:259


splitNodes

Private splitNodes(nodes): Object

Parameters

NameType
nodesBaseNode<Metadata>[]

Returns

Object

NameType
imageNodesImageNode<Metadata>[]
textNodesTextNode<Metadata>[]

Defined in

packages/core/src/indices/vectorStore/VectorStoreIndex.ts:367


fromDocuments

Static fromDocuments(documents, args?): Promise<VectorStoreIndex>

High level API: split documents, get embeddings, and build index.

Parameters

NameType
documentsDocument<Metadata>[]
argsVectorIndexOptions

Returns

Promise<VectorStoreIndex>

Defined in

packages/core/src/indices/vectorStore/VectorStoreIndex.ts:201


fromVectorStore

Static fromVectorStore(vectorStore, serviceContext): Promise<VectorStoreIndex>

Parameters

NameType
vectorStoreVectorStore
serviceContextServiceContext

Returns

Promise<VectorStoreIndex>

Defined in

packages/core/src/indices/vectorStore/VectorStoreIndex.ts:219


init

Static init(options): Promise<VectorStoreIndex>

The async init function creates a new VectorStoreIndex.

Parameters

NameType
optionsVectorIndexOptions

Returns

Promise<VectorStoreIndex>

Defined in

packages/core/src/indices/vectorStore/VectorStoreIndex.ts:80


setupIndexStructFromStorage

Static Private setupIndexStructFromStorage(indexStore, options): Promise<undefined | IndexDict>

Parameters

NameType
indexStoreBaseIndexStore
optionsIndexStructOptions

Returns

Promise<undefined | IndexDict>

Defined in

packages/core/src/indices/vectorStore/VectorStoreIndex.ts:118