VectorDatabaseSearch
VectorDatabaseSearch[db,vector]
gives the element of the vector database db nearest to vector.
VectorDatabaseSearch[db,vector,n]
gives the n nearest vectors.
VectorDatabaseSearch[db,vector,prop,n]
returns the property prop associated with the result.
VectorDatabaseSearch[db,vectorf,…]
filters the results using the function f.
Details
- VectorDatabaseSearch performs a search on the vector database using a query to find and retrieve similar items.
- This function is used for tasks like finding similar documents, images or products via their vector representation, enhancing capabilities in recommendation systems and content discovery.
- Valid db specifications are:
-
"name" a string matching a named vector database VectorDatabaseObject[…] a valid VectorDatabaseObject - The vector must have the same length as the vector stored in the database. »
- The input to the function f is the same annotation specified when the database was created. »
- Possible property values prop include:
-
"Distance" the distance from vector "Element" the vector found to be nearest "Index" the element position in the database "Metadata" metadata associated with the element "Metadata"tag a specific metadata value "Metadata"->{"tag1",…} multiple metadata values {prop1,…} a list of properties All a Dataset with all the properties
Examples
open allclose allBasic Examples (1)
Scope (4)
Initialize a new vector database with a list of vectors:
Find the first nearest vector:
Find the list of the first three nearest vectors:
Find the vectors together with their distance:
List all the properties of each result:
Create a vector database with labeled arrays:
The label is automatically returned when searching:
Filter the result to only contain vectors with a specific label:
Create a vector database with metadata associated to each vector:
Search for the two nearest vectors:
Return only vectors matching a specified filter:
Create a vector database with multiple metadata elements associated to each vector:
All metadata is returned when searching:
Return only the specified metadata:
Return multiple metadata elements with labels:
Applications (1)
Image Search (1)
Properties & Relations (2)
Possible Issues (2)
Create a database with 2D vectors:
It is not possible to search using query vectors of different lengths:
Create a vector database with multiple metadata elements associated to each vector:
Only elements that fit the specified filters will be returned, even if this is less than the number requested:
Text
Wolfram Research (2024), VectorDatabaseSearch, Wolfram Language function, https://reference.wolfram.com/language/ref/VectorDatabaseSearch.html (updated 2025).
CMS
Wolfram Language. 2024. "VectorDatabaseSearch." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2025. https://reference.wolfram.com/language/ref/VectorDatabaseSearch.html.
APA
Wolfram Language. (2024). VectorDatabaseSearch. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/VectorDatabaseSearch.html