AddToVectorDatabase[db,{vec1,…}]
adds a list of vectors veci to the VectorDatabaseObject[…] db.
AddToVectorDatabase[db,{vec1,…}{val1,…}]
adds new vector veci and associated value vali to the database db.
AddToVectorDatabase
AddToVectorDatabase[db,{vec1,…}]
adds a list of vectors veci to the VectorDatabaseObject[…] db.
AddToVectorDatabase[db,{vec1,…}{val1,…}]
adds new vector veci and associated value vali to the database db.
Details
- AddToVectorDatabase extends an existing VectorDatabaseObject with additional data, expanding the database’s storage and search capabilities.
- The database can be specified using:
-
"string" a string matching a named vector database db a VectorDatabaseObject - Possible values for the data to be added include:
-
{vec1,…} a list of vectors {vec1val1,…} a list of vectors and associated values {vec1,…}{val1,…} a rule between vectors and values - If db contains annotated vectors, each new veci should be tagged the same way. »
- Accepted forms of vali include:
-
"string" string labels <|"tag1"v1,…|> an association of tags and metadata values
Examples
open all close allBasic Examples (1)
Scope (6)
Data Sources (2)
Add a list of vectors to an empty database:
AddToVectorDatabase[CreateVectorDatabase[], {{1, 2, 3}, {4, 5, 6}}]Create a database with existing vectors:
db = CreateVectorDatabase[{{1, 2, 3}, {4, 5, 6}}]Add a new vector to the existing database:
AddToVectorDatabase[db, {{6, 7, 8}}]Add multiple vectors to the existing database:
AddToVectorDatabase[db, {{7, 8, 9}, {10, 11, 12}}]Metadata (4)
Add vectors together with simple labels to an empty database:
AddToVectorDatabase[CreateVectorDatabase[], {{1, 2, 3} -> "A", {2, 3, 4} -> "B"}]Create a database with vectors annotated with single labels:
db = CreateVectorDatabase[{{1, 2, 3} -> "A"}]Add new vectors together with their labels:
AddToVectorDatabase[db, {{2, 3, 4} -> "B", {5, 6, 7} -> "C"}]Add vectors together with annotations in an Association to an empty database:
AddToVectorDatabase[CreateVectorDatabase[], {{1, 2, 3} -> <|"tag1" -> 1, "tag2" -> "A"|>, {2, 3, 4} -> <|"tag1" -> 2, "tag2" -> "B"|>}]Create a database with vectors annotated with multiple tags:
db = CreateVectorDatabase[{{1, 2, 3} -> <|"tag1" -> "A", "tag2" -> 1|>, {4, 5, 6} -> <|"tag1" -> "B", "tag2" -> 2|>}]Add vectors together with labels in an Association to a populated database:
AddToVectorDatabase[db, {{1, 2, 3} -> <|"tag1" -> "A", "tag2" -> 3|>, {2, 3, 4} -> <|"tag1" -> "C", "tag2" -> 4|>}]Applications (1)
A single incorrect element will cause the database creation to fail:
data = {{1, 2}, {3, 4}, {5, 6, 7}, {8, 9}};
CreateVectorDatabase[data]To add all elements that are valid, create a empty database:
db = CreateVectorDatabase[]Use AddToVectorDatabase to incrementally add only the valid elements:
Do[AddToVectorDatabase[db, {vec}], {vec, data}]The three valid elements have been added to the database:
dbProperties & Relations (1)
Possible Issues (2)
db = CreateVectorDatabase[{{1, 2, 3}, {4, 5, 6}}]Additional vectors must be of the same dimensions as the input:
AddToVectorDatabase[db, {{6, 7}, {8, 9}}]Create a vector database with labeled vectors:
db = CreateVectorDatabase[{{1, 2, 3} -> "A", {4, 5, 6} -> "B"}]New elements must follow the same format:
AddToVectorDatabase[db, {1, 2, 3}]Add an annotation in order to add the vector:
AddToVectorDatabase[db, {{1, 2, 3} -> "C"}]Related Guides
History
Text
Wolfram Research (2024), AddToVectorDatabase, Wolfram Language function, https://reference.wolfram.com/language/ref/AddToVectorDatabase.html.
CMS
Wolfram Language. 2024. "AddToVectorDatabase." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/AddToVectorDatabase.html.
APA
Wolfram Language. (2024). AddToVectorDatabase. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/AddToVectorDatabase.html
BibTeX
@misc{reference.wolfram_2026_addtovectordatabase, author="Wolfram Research", title="{AddToVectorDatabase}", year="2024", howpublished="\url{https://reference.wolfram.com/language/ref/AddToVectorDatabase.html}", note=[Accessed: 13-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_addtovectordatabase, organization={Wolfram Research}, title={AddToVectorDatabase}, year={2024}, url={https://reference.wolfram.com/language/ref/AddToVectorDatabase.html}, note=[Accessed: 13-June-2026]}