This page covers configuration and management of View collection objects.

Object Overview

Collections define the groups by which source documents (metadata) are stored and made searchable within View.

Endpoint, URL, and Supported Methods

Objects are managed via the Lexi server API at [http|https]://[hostname]:[port]/v1.0/tenants/[tenant-guid]/graphrepositories

Supported methods include: GET HEAD PUT DELETE

Structure

Objects have the following structure:

{
    "GUID": "default",
    "TenantGUID": "default",
    "Name": "My first collection",
    "AllowOverwrites": true,
    "AdditionalData": "Created by setup",
    "CreatedUtc": "2024-07-10T05:11:51.000000Z"
}

Properties:

  • GUID GUID globally unique identifier for the object
  • TenantGUID GUID globally unique identifier for the tenant
  • Name string name of the object
  • AllowOverwrites bool indicates whether or not documents with a pre-existing key should overwrite previously-stored documents
  • AdditionalData string additional data, or notes, supplied by the administrator
  • CreatedUtc datetime timestamp from creation, in UTC time

Create

To create, call PUT /v1.0/tenants/[tenant-guid]/collections with the following properties using the Lexi server: Name

curl --location --request PUT 'http://view.homedns.org:8000/v1.0/tenants/00000000-0000-0000-0000-000000000000/collections' \
--header 'Content-Type: application/json' \
--header 'Authorization: ••••••' \
--data '{
    "Name": "My second collection",
    "AllowOverwrites": true,
    "AdditionalData": "Created by setup"
}'
import { ViewConfigurationSdk } from "view-sdk";

const api = new ViewConfigurationSdk(
  "default", //tenant Id
  "default", //access token
  "http://localhost:8000/" //endpoint
);

const createCollection = async () => {
  try {
    const response = await api.createCollection({
      Name: "My second collection",
      AllowOverwrites: true,
      AdditionalData: "Created by setup",
    });
    console.log(response, "Collection created successfully");
  } catch (err) {
    console.log("Error creating collection:", err);
  }
};

createCollection();

Enumerate

Refer to the Enumeration page in REST API for details about the use of enumeration APIs.

Enumerate objects by using GET /v2.0/tenants/[tenant-guid]/collections. The resultant object will appear as:

{
    "Success": true,
    "Timestamp": {
        "Start": "2024-10-21T02:36:37.677751Z",
        "TotalMs": 23.58,
        "Messages": {}
    },
    "MaxResults": 10,
    "IterationsRequired": 1,
    "EndOfResults": true,
    "RecordsRemaining": 16,
    "Objects": [
        {
            "GUID": "example-collection",
            ... collection details ...
        },
        { ... }
    ],
    "ContinuationToken": "[continuation-token]"
}
curl --location 'http://view.homedns.org:8000/v2.0/tenants/00000000-0000-0000-0000-000000000000/collections' \
--header 'Authorization: ••••••'
import { ViewConfigurationSdk } from "view-sdk";

const api = new ViewConfigurationSdk(
  "default", //tenant Id
  "default", //access token
  "http://localhost:8000/" //endpoint
);

const enumerateCollections = async () => {
  try {
    const response = await api.enumerateCollections();
    console.log(response, "Collections fetched successfully");
  } catch (err) {
    console.log("Error fetching Collections:", err);
  }
};

enumerateCollections();

Read

To read an object by GUID, call GET /v1.0/tenants/[tenant-guid]/collections/[collection-guid]. If the object exists, it will be returned as a JSON object in the response body. If it does not exist, a 404 will be returned with a NotFound error response.

curl --location 'http://view.homedns.org:8000/v1.0/tenants/00000000-0000-0000-0000-000000000000/collections/00000000-0000-0000-0000-000000000000' \
--header 'Authorization: ••••••'
import { ViewConfigurationSdk } from "view-sdk";

const api = new ViewConfigurationSdk(
  "default", //tenant Id
  "default", //access token
  "http://localhost:8000/" //endpoint
);

const readCollection = async () => {
  try {
    const response = await api.retrieveCollection(
      "91928e04-914b-41b0-af1c-fc3575749d17"
    );
    console.log(response, "Collection fetched successfully");
  } catch (err) {
    console.log("Error fetching Collection:", err);
  }
};
readCollection();

Read all

o read all objects, call GET /v1.0/tenants/[tenant-guid]/collections/. If the object exists, it will be returned as an array of JSON object in the response body

curl --location 'http://view.homedns.org:8000/v1.0/tenants/00000000-0000-0000-0000-000000000000/collections' \
--header 'Authorization: ••••••'
import { ViewConfigurationSdk } from "view-sdk";

const api = new ViewConfigurationSdk(
  "default", //tenant Id
  "default", //access token
  "http://localhost:8000/" //endpoint
);

const readAllCollections = async () => {
  try {
    const response = await api.retrieveCollections();
    console.log(response, "All collections fetched successfully");
  } catch (err) {
    console.log("Error fetching Collections:", err);
  }
};

readAllCollections();


Retrieve stats

To retrieve collection stats by GUID, call call GET /v1.0/tenants/[tenant-guid]/collections/[collection-guid]?stats

curl --location 'http://view.homedns.org:8000/v1.0/tenants/00000000-0000-0000-0000-000000000000/collections/00000000-0000-0000-0000-000000000000?stats=null' \
--header 'Authorization: ••••••'
import { ViewConfigurationSdk } from "view-sdk";

const api = new ViewConfigurationSdk(
  "default", //tenant Id
  "default", //access token
  "http://localhost:8000/" //endpoint
);

const retrieveCollectionStats = async () => {
  try {
    const response = await api.retrieveCollectionStatistics(
      "00000000-0000-0000-0000-000000000000"
    );
    console.log(response, "Collection stats fetched successfully");
  } catch (err) {
    console.log("Error fetching Collection stats:", err);
  }
};

retrieveCollectionStats();

Delete

To delete an object by GUID, call DELETE /v1.0/tenants/[tenant-guid]/collections/[collection-guid].

curl --location --request DELETE 'http://view.homedns.org:8000/v1.0/tenants/00000000-0000-0000-0000-000000000000/collections/00000000-0000-0000-0000-000000000000' \
--header 'Authorization: ••••••' \curl --location --head 'http://view.homedns.org:8000/v1.0/tenants/00000000-0000-0000-0000-000000000000/collections/00000000-0000-0000-0000-000000000000' \
--header 'Authorization: ••••••'
import { ViewConfigurationSdk } from "view-sdk";

const api = new ViewConfigurationSdk(
  "default", //tenant Id
  "default", //access token
  "http://localhost:8000/" //endpoint
);
const deleteCollection = async () => {
  try {
    const response = await api.deleteCollection(
      "45ab9c42-eac4-49e0-be91-747393e81b89"
    );
    console.log(response, "Collection deleted successfully");
  } catch (err) {
    console.log("Error deleting Collection:", err);
  }
};

deleteCollection();

Check Existence

Note: the HEAD method can be used as an alternative to get to simply check the existence of the object. HEAD requests return either a 200/OK in the event the object exists, or a 404/Not Found if not. No response body is returned with a HEAD request.

curl --location --head 'http://view.homedns.org:8000/v1.0/tenants/00000000-0000-0000-0000-000000000000/collections/00000000-0000-0000-0000-000000000000' \
--header 'Authorization: ••••••'
import { ViewConfigurationSdk } from "view-sdk";

const api = new ViewConfigurationSdk(
  "default", //tenant Id
  "default", //access token
  "http://localhost:8000/" //endpoint
);

const collectionExists = async () => {
  try {
    const response = await api.existsCollection(
      "91928e04-914b-41b0-af1c-fc3575749d17"
    );
    console.log(response, "Collection exists");
  } catch (err) {
    console.log("Error checking Collection:", err);
  }
};

collectionExists();