Class: VectorStoreIndex
The VectorStoreIndex, an index that stores the nodes only according to their vector embedings.
Hierarchy
Constructors
constructor
• Private
new VectorStoreIndex(init
)
Parameters
Name | Type |
---|---|
init | VectorIndexConstructorProps |
Overrides
Defined in
packages/core/src/indices/vectorStore/VectorStoreIndex.ts:42
Properties
docStore
• docStore: BaseDocumentStore
Inherited from
Defined in
packages/core/src/indices/BaseIndex.ts:156
indexStore
• Optional
indexStore: BaseIndexStore
Inherited from
Defined in
packages/core/src/indices/BaseIndex.ts:158
indexStruct
• indexStruct: IndexDict
Inherited from
Defined in
packages/core/src/indices/BaseIndex.ts:159
serviceContext
• serviceContext: ServiceContext
Inherited from
Defined in
packages/core/src/indices/BaseIndex.ts:154
storageContext
• storageContext: StorageContext
Inherited from
Defined in
packages/core/src/indices/BaseIndex.ts:155
vectorStore
• vectorStore: VectorStore
Overrides
Defined in
packages/core/src/indices/vectorStore/VectorStoreIndex.ts:40
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
Name | Type | Description |
---|---|---|
options? | Object | you can supply your own custom Retriever and ResponseSynthesizer |
options.nodePostprocessors? | BaseNodePostprocessor [] | - |
options.preFilters? | unknown | - |
options.responseSynthesizer? | ResponseSynthesizer | - |
options.retriever? | BaseRetriever | - |
Returns
Overrides
Defined in
packages/core/src/indices/vectorStore/VectorStoreIndex.ts:247
asRetriever
▸ asRetriever(options?
): VectorIndexRetriever
Create a new retriever from the index.
Parameters
Name | Type |
---|---|
options? | any |
Returns
Overrides
Defined in
packages/core/src/indices/vectorStore/VectorStoreIndex.ts:243
deleteRefDoc
▸ deleteRefDoc(refDocId
, deleteFromDocStore?
): Promise
<void
>
Parameters
Name | Type | Default value |
---|---|---|
refDocId | string | undefined |
deleteFromDocStore | boolean | true |
Returns
Promise
<void
>
Overrides
Defined in
packages/core/src/indices/vectorStore/VectorStoreIndex.ts:287
insert
▸ insert(document
): Promise
<void
>
Insert a document into the index.
Parameters
Name | Type |
---|---|
document | Document <Metadata > |
Returns
Promise
<void
>
Inherited from
Defined in
packages/core/src/indices/BaseIndex.ts:190
insertNodes
▸ insertNodes(nodes
): Promise
<void
>
Parameters
Name | Type |
---|---|
nodes | BaseNode <Metadata >[] |
Returns
Promise
<void
>
Overrides
Defined in
packages/core/src/indices/vectorStore/VectorStoreIndex.ts:262
buildIndexFromNodes
▸ Static
buildIndexFromNodes(nodes
, serviceContext
, vectorStore
, docStore
, indexDict?
): Promise
<IndexDict
>
Get embeddings for nodes and place them into the index.
Parameters
Name | Type |
---|---|
nodes | BaseNode <Metadata >[] |
serviceContext | ServiceContext |
vectorStore | VectorStore |
docStore | BaseDocumentStore |
indexDict? | IndexDict |
Returns
Promise
<IndexDict
>
Defined in
packages/core/src/indices/vectorStore/VectorStoreIndex.ts:153
fromDocuments
▸ Static
fromDocuments(documents
, args?
): Promise
<VectorStoreIndex
>
High level API: split documents, get embeddings, and build index.
Parameters
Name | Type |
---|---|
documents | Document <Metadata >[] |
args | Object |
args.serviceContext? | ServiceContext |
args.storageContext? | StorageContext |
Returns
Promise
<VectorStoreIndex
>
Defined in
packages/core/src/indices/vectorStore/VectorStoreIndex.ts:197
fromVectorStore
▸ Static
fromVectorStore(vectorStore
, serviceContext
): Promise
<VectorStoreIndex
>
Parameters
Name | Type |
---|---|
vectorStore | VectorStore |
serviceContext | ServiceContext |
Returns
Promise
<VectorStoreIndex
>
Defined in
packages/core/src/indices/vectorStore/VectorStoreIndex.ts:222
getNodeEmbeddingResults
▸ Static
getNodeEmbeddingResults(nodes
, serviceContext
, logProgress?
): Promise
<BaseNode
<Metadata
>[]>
Get the embeddings for nodes.
Parameters
Name | Type | Default value | Description |
---|---|---|---|
nodes | BaseNode <Metadata >[] | undefined | |
serviceContext | ServiceContext | undefined | |
logProgress | boolean | false | log progress to console (useful for debugging) |
Returns
Defined in
packages/core/src/indices/vectorStore/VectorStoreIndex.ts:124
init
▸ Static
init(options
): Promise
<VectorStoreIndex
>
The async init function should be called after the constructor. This is needed to handle persistence.
Parameters
Name | Type |
---|---|
options | VectorIndexOptions |
Returns
Promise
<VectorStoreIndex
>
Defined in
packages/core/src/indices/vectorStore/VectorStoreIndex.ts:53