Comprehensive guide to performing vector search operations including inner product, cosine distance, and L2 distance searches in the View Vector Database.
Overview
Vector search operations enable AI-powered similarity search and document discovery using vector embeddings. The View Vector Database supports multiple distance metrics including inner product, cosine distance, and L2 distance calculations for comprehensive semantic search capabilities.
Vector search operations are performed via the View Vector API at [http|https]://[hostname]:[port]/v1.0/tenants/[tenant-guid]/vectorrepositories/[vector-repository-guid]/search
and support advanced search functionality including embeddings discovery and similarity-based document retrieval.
Inner Product Search
Performs inner product similarity search using POST /v1.0/tenants/[tenant-guid]/vectorrepositories/[vector-repository-guid]/search
. Inner product search calculates the dot product between query vectors and stored embeddings to find the most similar documents based on vector alignment.
Request Parameters
Required Parameters
- SearchType (string, Body, Required): Must be set to "InnerProduct" for inner product search
- MaxResults (integer, Body, Required): Maximum number of search results to return
- Embeddings (array, Body, Required): Array of floating-point numbers representing the query vector
Optional Parameters
- VectorRepositoryGUID (GUID, Body, Optional): GUID of the vector repository to search within
curl --location 'http://view.homedns.org:8000/v1.0/tenants/00000000-0000-0000-0000-000000000000/vectorrepositories/00000000-0000-0000-0000-000000000000/search' \
--header 'Content-Type: application/json' \
--header 'Authorization: ••••••' \
--data '{
"SearchType": "InnerProduct",
"MaxResults": 5,
"Embeddings": []
}'
import { ViewVectorProxySdk } from "view-sdk";
const api = new ViewVectorProxySdk(
"http://localhost:8000/", //endpoint
"<tenant-guid>", //tenant Id
"default" //access key
);
const vectorSearch = async () => {
try {
const response = await api.VectorSearch.vectorSearch(
"<vector-repository-guid>",
{
SearchType: "InnerProduct",
MaxResults: 5,
Embeddings: [ ],
}
);
console.log(response, "Vector search response");
} catch (err) {
console.log("Error vector search:", err);
}
};
vectorSearch();
import view_sdk
from view_sdk import vector
from view_sdk.sdk_configuration import Service
sdk = view_sdk.configure(
access_key="default",
base_url="localhost",
tenant_guid="tenant-guid",
service_ports={Service.VECTOR: 8000},
)
def innerProductSearch():
response = vector.Search.search(
SearchType = "InnerProduct",
MaxResults = 5,
Embeddings = [0.16624743426880373,-0.01494671253675528]
)
print(response)
innerProductSearch()
using View.Sdk;
using View.Sdk.Vector;
ViewVectorSdk sdk = new ViewVectorSdk(Guid.Parse("<tenant-guid>"),"default", "http://localhost:8000/");
VectorSearchRequest searchRequest = new VectorSearchRequest
{
VectorRepositoryGUID = Guid.Parse("<vector-repository-guid>"),
SearchType = VectorSearchTypeEnum.InnerProduct,
MaxResults = 5,
Embeddings = new List<float> { 0.16624743f, -0.01494671f, -0.94218636f }
};
List<VectorChunk> response = await sdk.Vector.Search(searchRequest);
Response
Returns an array of vector chunks with similarity scores, document metadata, and embeddings information:
[
{
"DocumentGUID": "3f706ae4-ea86-4169-aa40-0870b0f8b9ad",
"TenantGUID": "00000000-0000-0000-0000-000000000000",
"CollectionGUID": "00000000-0000-0000-0000-000000000000",
"SourceDocumentGUID": "b213780c-1de1-4e7a-a87f-fb43807f2009",
"BucketGUID": "00000000-0000-0000-0000-000000000000",
"VectorRepositoryGUID": "00000000-0000-0000-0000-000000000000",
"GraphNodeIdentifier": "",
"ObjectGUID": "75019061-9a1d-457e-0000-f583b850f7ea",
"ObjectKey": "https://domain.com/project/stevens-cresto",
"ObjectVersion": "1",
"Model": "sentence-transformers/all-MiniLM-L6-v2",
"CellGUID": "c86eb1b0-0000-47e1-a993-291929384d69",
"CellType": "Text",
"CellMD5Hash": "******",
"CellSHA1Hash": "******",
"CellSHA256Hash": "******",
"CellPosition": 2,
"ChunkGUID": "b50913e5-6d9b-0000-a8ab-4ba86f694ab8",
"ChunkMD5Hash": "******",
"ChunkSHA1Hash": "******",
"ChunkSHA256Hash": "******",
"ChunkPosition": 0,
"ChunkLength": "Text content",
"Content": "",
"Score": 0.2749193608760834,
"Distance": 0,
"CreatedUtc": "2025-04-08T10:26:22.000000Z",
"Embeddings": [
-0.05686976
]
},
Cosine Distance Search
Performs cosine distance similarity search using POST /v1.0/tenants/[tenant-guid]/vectorrepositories/[vector-repository-guid]/search
. Cosine distance search measures the angle between query vectors and stored embeddings, providing similarity results based on vector direction rather than magnitude.
Request Parameters
Required Parameters
- SearchType (string, Body, Required): Must be set to "CosineDistance" for cosine distance search
- MaxResults (integer, Body, Required): Maximum number of search results to return
- Embeddings (array, Body, Required): Array of floating-point numbers representing the query vector
Optional Parameters
- VectorRepositoryGUID (GUID, Body, Optional): GUID of the vector repository to search within
curl --location 'http://view.homedns.org:8000/v1.0/tenants/00000000-0000-0000-0000-000000000000/vectorrepositories/00000000-0000-0000-0000-000000000000/search' \
--header 'Content-Type: application/json' \
--header 'Authorization: ••••••' \
--data '{
"SearchType": "CosineDistance",
"MaxResults": 5,
"Embeddings": []
}'
import { ViewVectorProxySdk } from "view-sdk";
const api = new ViewVectorProxySdk(
"http://localhost:8000/", //endpoint
"<tenant-guid>", //tenant Id
"default" //access key
);
const vectorSearch = async () => {
try {
const response = await api.VectorSearch.vectorSearch(
"<vector-repository-guid>",
{
SearchType: "CosineDistance",
MaxResults: 5,
Embeddings: [ ],
}
);
console.log(response, "Vector search response");
} catch (err) {
console.log("Error vector search:", err);
}
};
vectorSearch();
import view_sdk
from view_sdk import vector
from view_sdk.sdk_configuration import Service
sdk = view_sdk.configure(
access_key="default",
base_url="localhost",
tenant_guid="tenant-guid",
service_ports={Service.VECTOR: 8000},
)
def innerProductSearch():
response = vector.Search.search(
SearchType = "CosineDistance",
MaxResults = 5,
Embeddings = [0.16624743426880373,-0.01494671253675528]
)
print(response)
innerProductSearch()
using View.Sdk;
using View.Sdk.Vector;
ViewVectorSdk sdk = new ViewVectorSdk(Guid.Parse("<tenant-guid>"),"default", "http://localhost:8000/");
VectorSearchRequest searchRequest = new VectorSearchRequest
{
VectorRepositoryGUID = Guid.Parse("<vector-repository-guid>"),
SearchType = VectorSearchTypeEnum.CosineDistance,
MaxResults = 5,
Embeddings = new List<float> { -0.99624743f, 0.01494671f }
};
List<VectorChunk> response = await sdk.Vector.Search(searchRequest);
Response
Returns an array of vector chunks with cosine similarity scores, document metadata, and embeddings information.
L2 Distance Search
Performs L2 (Euclidean) distance similarity search using POST /v1.0/tenants/[tenant-guid]/vectorrepositories/[vector-repository-guid]/search
. L2 distance search calculates the Euclidean distance between query vectors and stored embeddings, providing similarity results based on geometric distance in vector space.
Request Parameters
Required Parameters
- SearchType (string, Body, Required): Must be set to "L2Distance" for L2 distance search
- MaxResults (integer, Body, Required): Maximum number of search results to return
- Embeddings (array, Body, Required): Array of floating-point numbers representing the query vector
Optional Parameters
- VectorRepositoryGUID (GUID, Body, Optional): GUID of the vector repository to search within
curl --location 'http://view.homedns.org:8000/v1.0/tenants/00000000-0000-0000-0000-000000000000/vectorrepositories/00000000-0000-0000-0000-000000000000/search' \
--header 'Content-Type: application/json' \
--header 'Authorization: ••••••' \
--data '{
"SearchType": "L2Distance",
"MaxResults": 5,
"Embeddings": []
}'
import { ViewVectorProxySdk } from "view-sdk";
const api = new ViewVectorProxySdk(
"http://localhost:8000/", //endpoint
"<tenant-guid>", //tenant Id
"default" //access key
);
const vectorSearch = async () => {
try {
const response = await api.VectorSearch.vectorSearch(
"<vector-repository-guid>",
{
SearchType: "L2Distance",
MaxResults: 5,
Embeddings: [ ],
}
);
console.log(response, "Vector search response");
} catch (err) {
console.log("Error vector search:", err);
}
};
vectorSearch();
import view_sdk
from view_sdk import vector
from view_sdk.sdk_configuration import Service
sdk = view_sdk.configure(
access_key="default",
base_url="localhost",
tenant_guid="tenant-guid",
service_ports={Service.VECTOR: 8000},
)
def innerProductSearch():
response = vector.Search.search(
SearchType = "L2Distance",
MaxResults = 5,
Embeddings = [0.16624743426880373,-0.01494671253675528]
)
print(response)
innerProductSearch()
using View.Sdk;
using View.Sdk.Vector;
ViewVectorSdk sdk = new ViewVectorSdk(Guid.Parse("<tenant-guid>"),"default", "http://localhost:8000/");
VectorSearchRequest searchRequest = new VectorSearchRequest
{
VectorRepositoryGUID = Guid.Parse("<vector-repository-guid>"),
SearchType = VectorSearchTypeEnum.L2Distance,
MaxResults = 5,
Embeddings = new List<float> { 0.16624743f, -0.01494671f }
};
List<VectorChunk> response = await sdk.Vector.Search(searchRequest);
Response
Returns an array of vector chunks with L2 distance scores, document metadata, and embeddings information.
Find Embeddings
Searches for specific embeddings using hash-based criteria using POST /v1.0/tenants/[tenant-guid]/vectorrepositories/[vector-repository-guid]/find
. Enables discovery of embeddings by content hash values for content deduplication and retrieval operations.
Request Parameters
Required Parameters
- Criteria (array, Body, Required): Array of search criteria objects containing hash values
Optional Parameters
- VectorRepositoryGUID (GUID, Body, Optional): GUID of the vector repository to search within
curl --location 'http://view.homedns.org:8000/v1.0/tenants/00000000-0000-0000-0000-000000000000/vectorrepositories/00000000-0000-0000-0000-000000000000/find' \
--header 'Content-Type: application/json' \
--header 'Authorization: ••••••' \
--data '{
"Criteria": [
{
"SHA256Hash": "222"
},
{
"SHA256Hash": "111"
}
]
}'
import { ViewVectorProxySdk } from "view-sdk";
const api = new ViewVectorProxySdk(
"http://localhost:8000/", //endpoint
"<tenant-guid>", //tenant Id
"default" //access key
);;
const findEmbeddings = async () => {
try {
const response = await api.VectorSearch.findEmbeddings(
"<vector-repository-guid>",
{
Criteria: [
{
SHA256Hash: "222",
},
{
SHA256Hash: "111",
},
],
}
);
console.log(response, "Find embeddings response");
} catch (err) {
console.log("Error find embeddings:", err);
}
};
findEmbeddings();
import view_sdk
from view_sdk import vector
from view_sdk.sdk_configuration import Service
sdk = view_sdk.configure(
access_key="default",
base_url="localhost",
tenant_guid="tenant-guid",
service_ports={Service.VECTOR: 8000},
)
def findEmbeddings():
response = vector.Search.find_embeddings(
Criteria = [
{
"SHA256Hash": "222"
},
{
"SHA256Hash": "111"
}
]
)
print(response)
findEmbeddings()
using View.Sdk;
using View.Sdk.Vector;
using View.Sdk.Embeddings;
ViewVectorSdk sdk = new ViewVectorSdk(Guid.Parse("<tenant-guid>"),"default", "http://localhost:8000/");
FindEmbeddingsRequest embeddingRequest = new FindEmbeddingsRequest
{
VectorRepositoryGUID = Guid.Parse("<vector-repository-guid>"),
Criteria = new List<FindEmbeddingsObject>
{
new FindEmbeddingsObject { SHA256Hash = "222" },
new FindEmbeddingsObject { SHA256Hash = "111" }
}
};
FindEmbeddingsResult response = await sdk.Vector.Find(embeddingRequest);
Response
Returns a find embeddings result containing matching embeddings and their associated metadata.
Best Practices
When performing vector search operations in the View Vector Database, consider the following recommendations for optimal search performance, accuracy, and efficiency:
- Distance Metric Selection: Choose appropriate distance metrics based on your use case - inner product for magnitude-sensitive similarity, cosine distance for direction-based similarity, and L2 distance for geometric similarity
- Query Vector Quality: Ensure high-quality query vectors are generated using the same or compatible embedding models as your stored documents
- Result Set Sizing: Use appropriate MaxResults values to balance search performance with result completeness based on your application requirements
- Search Performance: Monitor search response times and optimize vector repository configurations for your expected query volumes
- Similarity Thresholds: Implement appropriate similarity score thresholds to filter results and improve search relevance
Next Steps
After successfully performing vector search operations, you can:
- Vector Document Management: Create and manage vector documents with comprehensive metadata and embeddings storage
- Semantic Analysis: Work with semantic cells and chunks for detailed content understanding and processing
- Embeddings Management: Implement comprehensive embeddings document management for vector storage and retrieval
- Search Optimization: Optimize search performance and implement advanced filtering and ranking algorithms
- AI Integration: Integrate vector search with AI applications for semantic document discovery and content analysis