Perform inner product, cosine distance and L2 distance Search vector

Inner product search

To do Inner product search , call POST /v1.0/tenants/[tenant-guid]/vectorrepositories/[vector-repository-guid]/search

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 vector = new ViewVectorProxySdk(
  "00000000-0000-0000-0000-000000000000", //tenant Id
  "default", //access token
  "http://localhost:8000/" //endpoint
);

const vectorSearch = async () => {
  try {
    const response = await vector.vectorSearch(
      "00000000-0000-0000-0000-000000000000",
      {
        SearchType: "InnerProduct",
        MaxResults: 5,
        Embeddings: [ ],
      }
    );
    console.log(response, "Vector search response");
  } catch (err) {
    console.log("Error vector search:", err);
  }
};

vectorSearch();

Response

[
    {
        "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

To do cosine distance search , call POST /v1.0/tenants/[tenant-guid]/vectorrepositories/[vector-repository-guid]/search

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 vector = new ViewVectorProxySdk(
  "00000000-0000-0000-0000-000000000000", //tenant Id
  "default", //access token
  "http://localhost:8000/" //endpoint
);


const vectorSearch = async () => {
  try {
    const response = await vector.vectorSearch(
      "00000000-0000-0000-0000-000000000000",
      {
        SearchType: "CosineDistance",
        MaxResults: 5,
        Embeddings: [ ],
      }
    );
    console.log(response, "Vector search response");
  } catch (err) {
    console.log("Error vector search:", err);
  }
};

vectorSearch();

L2 distance search

To L2 distance search , call POST /v1.0/tenants/[tenant-guid]/vectorrepositories/[vector-repository-guid]/search

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 vector = new ViewVectorProxySdk(
  "00000000-0000-0000-0000-000000000000", //tenant Id
  "default", //access token
  "http://localhost:8000/" //endpoint
);


const vectorSearch = async () => {
  try {
    const response = await vector.vectorSearch(
      "00000000-0000-0000-0000-000000000000",
      {
        SearchType: "L2Distance",
        MaxResults: 5,
        Embeddings: [ ],
      }
    );
    console.log(response, "Vector search response");
  } catch (err) {
    console.log("Error vector search:", err);
  }
};

vectorSearch();

Find embeddings

To , find embeddings call POST /v1.0/tenants/[tenant-guid]/vectorrepositories/[vector-repository-guid]/find

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 vector = new ViewVectorProxySdk(
  "00000000-0000-0000-0000-000000000000", //tenant Id
  "default", //access token
  "http://localhost:8000/" //endpoint
);

const findEmbeddings = async () => {
  try {
    const response = await vector.findEmbeddings(
      "00000000-0000-0000-0000-000000000000",
      {
        Criteria: [
          {
            SHA256Hash: "222",
          },
          {
            SHA256Hash: "111",
          },
        ],
      }
    );
    console.log(response, "Find embeddings response");
  } catch (err) {
    console.log("Error find embeddings:", err);
  }
};

findEmbeddings();