This section introduces methods for managing various indexes and LTE status for properties in graphs.
Index
showIndex()
Retrieves all indexes from the graph.
Parameters
config: RequestConfig
(Optional): Request configuration.
Returns
Index[]
: The list of retrieved indexes.
// Retrieves indexes in the graph 'miniCircle'
const requestConfig: RequestConfig = {
graph: "miniCircle",
};
const indexList = await conn.showIndex(requestConfig)
for (const index of indexList) {
console.log(index)
}
{id: '1', name: 'age_index', properties: 'year', schema: 'account', status: 'DONE', size: undefined, dbType: 0}
{id: '2', name: 'test_index', properties: 'year,float', schema: 'account', status: 'DONE', size: undefined, dbType: 0}
{id: "1", name: 'targetPostInd', properties: 'targetPost', schema: 'disagree', status: 'DONE', size: undefined, dbType: 1}
showNodeIndex()
Retrieves all node indexes from the graph.
Parameters
config: RequestConfig
(Optional): Request configuration.
Returns
Index[]
: The list of retrieved indexes.
// Retrieves node indexes in the graph 'miniCircle'
const requestConfig: RequestConfig = {
graph: "miniCircle",
};
const indexList = await conn.showNodeIndex(requestConfig)
for (const index of indexList) {
console.log(index)
}
{id: '1', name: 'age_index', properties: 'year', schema: 'account', status: 'DONE', size: undefined, dbType: 0}
{id: '2', name: 'test_index', properties: 'year,float', schema: 'account', status: 'DONE', size: undefined, dbType: 0}
showEdgeIndex()
Retrieves all edge indexes from the graph.
Parameters
config: RequestConfig
(Optional): Request configuration.
Returns
Index[]
: The list of retrieved indexes.
// Retrieves edge indexes in the graph 'miniCircle'
const requestConfig: RequestConfig = {
graph: "miniCircle",
};
const indexList = await conn.showEdgeIndex(requestConfig)
for (const index of indexList) {
console.log(index)
}
{id: '1', name: 'targetPostInd', properties: 'targetPost', schema: 'disagree', status: 'DONE', size: undefined, dbType: 1}
dropIndex()
Drops a specified index from the graph.
Parameters
dbType: DBType
: Type of the index (node or edge).indexName: string
: Name of the index.config: RequestConfig
(Optional): Request configuration.
Returns
Response
: Response of the request.
// Drops the node index 'test_index' from the graph 'miniCircle'
const requestConfig: RequestConfig = {
graph: "miniCircle",
};
const response = await conn.dropIndex(DBType.DBNODE,"test_index",requestConfig)
console.log(response.status?.message)
SUCCESS
dropNodeIndex()
Drops a specified node index from the graph.
Parameters
indexName: string
: Name of the index.config: RequestConfig
(Optional): Request configuration.
Returns
Response
: Response of the request.
// Drops the node index 'test_index' from the graph 'miniCircle'
const requestConfig: RequestConfig = {
graph: "miniCircle",
};
const response = await conn.dropNodeIndex("test_index",requestConfig)
console.log(response.status?.message)
SUCCESS
dropEdgeIndex()
Drops a specified edge index from the graph.
Parameters
indexName: string
: Name of the index.config: RequestConfig
(Optional): Request configuration.
Returns
Response
: Response of the request.
// Drops the edge index 'targetPostInd' from the graph 'miniCircle'
const requestConfig: RequestConfig = {
graph: "miniCircle",
};
const response = await conn.dropEdgeIndex("targetPostInd",requestConfig)
console.log(response.status?.message)
SUCCESS
Full-text
showFulltext()
Retrieves all full-text indexes from the graph.
Parameters
config: RequestConfig
(Optional): Request configuration.
Returns
Index[]
: The list of retrieved full-text indexes.
// Retrieves full-text indexes in the graph 'miniCircle'
const requestConfig: RequestConfig = {
graph: "miniCircle",
};
const fulltextList = await conn.showFulltext(requestConfig)
for (const fulltext of fulltextList) {
console.log(fulltext)
}
Index{id: undefined, name: 'name', properties: 'name', schema: 'account', status: 'DONE', size: undefined, dbType: 0}
Index{id: undefined, name: 'Content', properties: 'content', schema: 'review', status: 'DONE', size: undefined, dbType: 1}
showNodeFulltext()
Retrieves all node full-text indexes from the graph.
Parameters
config: RequestConfig
(Optional): Request configuration.
Returns
Index[]
: The list of retrieved full-text indexes.
// Retrieves node full-text indexes in the graph 'miniCircle'
const requestConfig: RequestConfig = {
graph: "miniCircle",
};
const fulltextList = await conn.showNodeFulltext(requestConfig)
for (const fulltext of fulltextList) {
console.log(fulltext)
};
Index{id: undefined, name: 'name', properties: 'name', schema: 'account', status: 'DONE', size: undefined, dbType: 0}
showEdgeFulltext()
Retrieves all edge full-text indexes from the graph.
Parameters
config: RequestConfig
(Optional): Request configuration.
Returns
Index[]
: The list of retrieved full-text indexes.
// Retrieves edge full-text indexes in the graph 'miniCircle'
const requestConfig: RequestConfig = {
graph: "miniCircle",
};
const fulltextList = await conn.showEdgeFulltext(requestConfig)
for (const fulltext of fulltextList) {
console.log(fulltext)
}
Index{id: undefined, name: 'Content', properties: 'content', schema: 'review', status: 'DONE', size: undefined, dbType: 1}
createFulltext()
Creates a full-text index in the graph.
Parameters
dbType: DBType
: Type of the full-text index (node or edge).schemaName: string
: Name of the schema.propertyName: string
: Name of the property.indexName: string
: Name of the full-text index.config: RequestConfig
(Optional): Request configuration.
Returns
JobResponse
: Response of the request.
// Creates a full-text index 'moviePlot' for the property 'plot' of the 'movie' nodes
const requestConfig: RequestConfig = {
graph: "miniCircle",
};
const response = await conn.createFulltext(DBType.DBNODE,"movie","plot","moviePlot",requestConfig)
const jobID = response.jobId;
await new Promise(resolve => setTimeout(resolve, 3000))
const jobs = await conn.showJob(jobID, requestConfig);
for (const job of jobs) {
console.log(`${job.id} - ${job.status}`);
}
66 - FINISHED
66_1 - FINISHED
66_2 - FINISHED
66_3 - FINISHED
createNodeFulltext()
Creates a node full-text index in the graph.
Parameters
schemaName: string
: Name of the schema.propertyName: string
: Name of the property.indexName: string
: Name of the full-text index.config: RequestConfig
(Optional): Request configuration.
Returns
JobResponse
: Response of the request.
// Creates a full-text index 'moviePlot' for the property 'plot' of the 'movie' nodes
const requestConfig: RequestConfig = {
graph: "miniCircle",
};
const response = await conn.createNodeFulltext("movie","plot","moviePlot",requestConfig)
const jobID = response.jobId;
await new Promise(resolve => setTimeout(resolve, 3000))
const jobs = await conn.showJob(jobID, requestConfig);
for (const job of jobs) {
console.log(`${job.id} - ${job.status}`);
}
68 - FINISHED
68_1 - FINISHED
68_2 - FINISHED
68_3 - FINISHED
createEdgeFulltext()
Creates an edge full-text index in the graph.
Parameters
schemaName: string
: Name of the schema.propertyName: string
: Name of the property.indexName: string
: Name of the full-text index.config: RequestConfig
(Optional): Request configuration.
Returns
JobResponse
: Response of the request.
// Creates a full-text index 'agreeNotes' for the property 'notes' of the 'agree' edges
const requestConfig: RequestConfig = {
graph: "miniCircle",
};
const response = await conn.createEdgeFulltext("agree","notes","agreeNotes",requestConfig)
const jobID = response.jobId;
await new Promise(resolve => setTimeout(resolve, 3000))
const jobs = await conn.showJob(jobID, requestConfig);
for (const job of jobs) {
console.log(`${job.id} - ${job.status}`);
}
69 - FINISHED
69_1 - FINISHED
69_2 - FINISHED
69_3 - FINISHED
dropFulltext()
Drops a full-text index from the graph.
Parameters
dyType: DBType
: Type of the full-text index (node or edge).fulltextName: string
: Name of the full-text index.config: RequestConfig
(Optional): Request configuration.
Returns
Response
: Response of the request.
// Drops the node full-index 'moviePlot' from the graph 'miniCircle'
const requestConfig: RequestConfig = {
graph: "miniCircle",
};
const response = await conn.dropFulltext(DBType.DBNODE,"moviePlot",requestConfig)
console.log(response.status?.message)
SUCCESS
LTE
lte()
Loads a property to the computing engine.
Parameters
dbType: DBType
: Type of the property (node or edge).propertyName: string
: Name of the property.schemaName: string
(Optional): Name of the schema; all schemas are specified when it is ignored.config: RequestConfig
(Optional): Request configuration.
Returns
JobResponse
: Response of the request.
// Loads the property 'year' of 'account' nodes to the computing engine
const requestConfig: RequestConfig = {
graph: "miniCircle",
};
const response = await conn.lte(DBType.DBNODE,"year","account",requestConfig)
const jobID = response.jobId;
await new Promise(resolve => setTimeout(resolve, 3000))
const jobs = await conn.showJob(jobID, requestConfig);
for (const job of jobs) {
console.log(`${job.id} - ${job.status}`);
}
53 - FINISHED
53_1 - FINISHED
53_2 - FINISHED
53_3 - FINISHED
ufe()
Unloads a property from the computing engine.
Parameters
dbType: DBType
: Type of the property (node or edge).propertyName: string
: Name of the property.schemaName: string
(Optional): Name of the schema; all schemas are specified when it is ignored.config: RequestConfig
(Optional): Request configuration.
Returns
Response
: Response of the request.
// Unloads the property 'year' of 'account' nodes from the computing engine
const requestConfig: RequestConfig = {
graph: "miniCircle",
};
const response = await conn.ufe(DBType.DBNODE,"year","account",requestConfig)
console.log(response.status?.message)
SUCCESS
Full Example
import { UltipaDriver } from "@ultipa-graph/ultipa-driver";
import { ULTIPA } from "@ultipa-graph/ultipa-driver/dist/types";
import { RequestConfig } from "@ultipa-graph/ultipa-driver/dist/types/types";
let sdkUsage = async () => {
// URI example: ultipaConfig.hosts: ["mqj4zouys.us-east-1.cloud.ultipa.com:60010"]
const ultipaConfig: ULTIPA.UltipaConfig = {
hosts: ["192.168.1.85:60061", "192.168.1.87:60061", "192.168.1.88:60061"],
username: "<username>",
password: "<password>"
};
const conn = new UltipaDriver(ultipaConfig);
const isSuccess = await conn.test();
console.log(`Connection succeeds: ${isSuccess}`);
// Retrieves indexes in the graph 'miniCircle'
const requestConfig: RequestConfig = {
graph: "miniCircle",
};
const indexList = await conn.showIndex(requestConfig);
for (const index of indexList) {
console.log(index);
}
};
sdkUsage().catch(console.error);