Skip to main content

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

indices/vectorStore/VectorStoreIndex.ts:36

Properties

docStore

docStore: BaseDocumentStore

Inherited from

BaseIndex.docStore

Defined in

indices/BaseIndex.ts:117


indexStore

Optional indexStore: BaseIndexStore

Inherited from

BaseIndex.indexStore

Defined in

indices/BaseIndex.ts:119


indexStruct

indexStruct: IndexDict

Inherited from

BaseIndex.indexStruct

Defined in

indices/BaseIndex.ts:120


serviceContext

serviceContext: ServiceContext

Inherited from

BaseIndex.serviceContext

Defined in

indices/BaseIndex.ts:115


storageContext

storageContext: StorageContext

Inherited from

BaseIndex.storageContext

Defined in

indices/BaseIndex.ts:116


vectorStore

vectorStore: VectorStore

Overrides

BaseIndex.vectorStore

Defined in

indices/vectorStore/VectorStoreIndex.ts:34

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.responseSynthesizer?ResponseSynthesizer-
options.retriever?BaseRetriever-

Returns

BaseQueryEngine

Overrides

BaseIndex.asQueryEngine

Defined in

indices/vectorStore/VectorStoreIndex.ts:215


asRetriever

asRetriever(options?): VectorIndexRetriever

Create a new retriever from the index.

Parameters

NameType
options?any

Returns

VectorIndexRetriever

Overrides

BaseIndex.asRetriever

Defined in

indices/vectorStore/VectorStoreIndex.ts:211


buildIndexFromNodes

Static buildIndexFromNodes(nodes, serviceContext, vectorStore, docStore): Promise<IndexDict>

Get embeddings for nodes and place them into the index.

Parameters

NameType
nodesBaseNode[]
serviceContextServiceContext
vectorStoreVectorStore
docStoreBaseDocumentStore

Returns

Promise<IndexDict>

Defined in

indices/vectorStore/VectorStoreIndex.ts:151


fromDocuments

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

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

Parameters

NameType
documentsDocument[]
argsObject
args.serviceContext?ServiceContext
args.storageContext?StorageContext

Returns

Promise<VectorStoreIndex>

Defined in

indices/vectorStore/VectorStoreIndex.ts:186


getNodeEmbeddingResults

Static getNodeEmbeddingResults(nodes, serviceContext, logProgress?): Promise<NodeWithEmbedding[]>

Get the embeddings for nodes.

Parameters

NameTypeDefault valueDescription
nodesBaseNode[]undefined
serviceContextServiceContextundefined
logProgressbooleanfalselog progress to console (useful for debugging)

Returns

Promise<NodeWithEmbedding[]>

Defined in

indices/vectorStore/VectorStoreIndex.ts:123


init

Static init(options): Promise<VectorStoreIndex>

The async init function should be called after the constructor. This is needed to handle persistence.

Parameters

NameType
optionsVectorIndexOptions

Returns

Promise<VectorStoreIndex>

Defined in

indices/vectorStore/VectorStoreIndex.ts:47