本节介绍用于管理图中各类属性索引及LTE状态的方法。
索引
showIndex()
获取图中全部索引。
参数
config: RequestConfig
(可选):请求配置。
返回值
List<Index>
:获取的索引列表。
// Retrieves indexes in the graph 'miniCircle'
RequestConfig requestConfig = new RequestConfig();
requestConfig.setGraph("miniCircle");
List<Index> indexList = driver.showIndex(requestConfig);
for (Index index : indexList) {
System.out.println(index);
}
Index(id=1, name=age_index, properties=year, schema=account, status=DONE, size=null, dbType=DBNODE)
Index(id=2, name=test_index, properties=year,float, schema=account, status=DONE, size=null, dbType=DBNODE)
Index(id=1, name=targetPostInd, properties=targetPost, schema=disagree, status=DONE, size=null, dbType=DBEDGE)
showNodeIndex()
获取图中全部点索引。
参数
config: RequestConfig
(可选):请求配置。
返回值
List<Index>
:获取的索引列表。
// Retrieves node indexes in the graph 'miniCircle'
RequestConfig requestConfig = new RequestConfig();
requestConfig.setGraph("miniCircle");
List<Index> indexList = driver.showNodeIndex(requestConfig);
for (Index index : indexList) {
System.out.println(index);
}
Index(id=1, name=age_index, properties=year, schema=account, status=DONE, size=null, dbType=DBNODE)
Index(id=2, name=test_index, properties=year,float, schema=account, status=DONE, size=null, dbType=DBNODE)
showEdgeIndex()
获取图中全部边索引。
参数
config: RequestConfig
(可选):请求配置。
返回值
List<Index>
:获取的索引列表。
// Retrieves edge indexes in the graph 'miniCircle'
RequestConfig requestConfig = new RequestConfig();
requestConfig.setGraph("miniCircle");
List<Index> indexList = driver.showEdgeIndex(requestConfig);
for (Index index : indexList) {
System.out.println(index);
}
Index(id=1, name=targetPostInd, properties=targetPost, schema=disagree, status=DONE, size=null, dbType=DBEDGE)
dropIndex()
从图中删除一个指定的索引。
参数
dbType: DBType
:索引类型(点或边)。indexName: str
:索引名称。config: RequestConfig
(可选):请求配置。
返回值
Response
:请求结果。
// Drops the node index 'test_index' from the graph 'miniCircle'
RequestConfig requestConfig = new RequestConfig();
requestConfig.setGraph("miniCircle");
Response response = driver.dropIndex(Ultipa.DBType.DBNODE, "test_index", requestConfig);
System.out.println(response.getStatus().getCode());
SUCCESS
dropNodeIndex()
从图中删除一个指定的点索引。
参数
indexName: String
:索引名称。config: RequestConfig
(可选):请求配置。
返回值
Response
:请求结果。
// Drops the node index 'test_index' from the graph 'miniCircle'
RequestConfig requestConfig = new RequestConfig();
requestConfig.setGraph("miniCircle");
Response response = driver.dropNodeIndex("test_index", requestConfig);
System.out.println(response.getStatus().getCode());
SUCCESS
dropEdgeIndex()
从图中删除一个指定的边索引。
参数
indexName: String
:索引名称。config: RequestConfig
(可选):请求配置。
返回值
Response
:请求结果。
// Drops the edge index 'targetPostInd' from the graph 'miniCircle'
RequestConfig requestConfig = new RequestConfig();
requestConfig.setGraph("miniCircle");
Response response = driver.dropEdgeIndex("targetPostInd", requestConfig);
System.out.println(response.getStatus().getCode());
SUCCESS
全文索引
showFulltext()
获取图中全部全文索引。
参数
config: RequestConfig
(可选):请求配置。
返回值
List<Index>
:获取的全文索引列表。
// Retrieves full-text indexes in the graph 'miniCircle'
RequestConfig requestConfig = new RequestConfig();
requestConfig.setGraph("miniCircle");
List<Index> fulltextList = driver.showFulltext(requestConfig);
for (Index fulltext : fulltextList) {
System.out.println(fulltext);
}
Index(id=null, name=name, properties=name, schema=account, status=DONE, size=null, dbType=DBNODE)
Index(id=null, name=Content, properties=content, schema=review, status=DONE, size=null, dbType=DBEDGE)
showNodeFulltext()
获取图中全部点的全文索引。
参数
config: RequestConfig
(可选):请求配置。
返回值
List<Index>
:获取的全文索引列表。
// Retrieves node full-text indexes in the graph 'miniCircle'
RequestConfig requestConfig = new RequestConfig();
requestConfig.setGraph("miniCircle");
List<Index> fulltextList = driver.showNodeFulltext(requestConfig);
for (Index fulltext : fulltextList) {
System.out.println(fulltext);
}
Index(id=null, name=name, properties=name, schema=account, status=DONE, size=null, dbType=DBNODE)
showEdgeFulltext()
获取图中全部边的全文索引。
参数
config: RequestConfig
(可选):请求配置。
返回值
List<Index>
:获取的全文索引列表。
// Retrieves edge full-text indexes in the graph 'miniCircle'
RequestConfig requestConfig = new RequestConfig();
requestConfig.setGraph("miniCircle");
List<Index> fulltextList = driver.showEdgeFulltext(requestConfig);
for (Index fulltext : fulltextList) {
System.out.println(fulltext);
}
Index(id=null, name=Content, properties=content, schema=review, status=DONE, size=null, dbType=DBEDGE)
createFulltext()
在图中创建一个全文索引。
参数
dbType: DBType
:全文索引类型(点或边)。schemaName: String
:Schema名称。propertyName: String
:属性名称。indexName: String
:全文索引名称。config: RequestConfig
(可选):请求配置。
返回值
JobResponse
:请求结果。
// Creates a full-text index 'moviePlot' for the property 'plot' of the 'movie' nodes
RequestConfig requestConfig = new RequestConfig();
requestConfig.setGraph("miniCircle");
JobResponse response = driver.createFulltext(Ultipa.DBType.DBNODE, "movie", "plot", "moviePlot", requestConfig);
String jobID = response.getJobId();
Thread.sleep(3000);
List<Job> jobs = driver.showJob(jobID, requestConfig);
for (Job job : jobs) {
System.out.println(job.getId() + " - " + job.getStatus());
}
66 - FINISHED
66_1 - FINISHED
66_2 - FINISHED
66_3 - FINISHED
createNodeFulltext()
在图中创建一个点的全文索引。
参数
schemaName: String
:Schema名称。propertyName: String
:属性名称。indexName: String
:全文索引名称。config: RequestConfig
(可选):请求配置。
返回值
JobResponse
:请求结果。
// Creates a full-text index 'moviePlot' for the property 'plot' of the 'movie' nodes
RequestConfig requestConfig = new RequestConfig();
requestConfig.setGraph("miniCircle");
JobResponse response = driver.createNodeFulltext("movie", "plot", "moviePlot", requestConfig);
String jobID = response.getJobId();
Thread.sleep(3000);
List<Job> jobs = driver.showJob(jobID, requestConfig);
for (Job job : jobs) {
System.out.println(job.getId() + " - " + job.getStatus());
}
68 - FINISHED
68_1 - FINISHED
68_2 - FINISHED
68_3 - FINISHED
createEdgeFulltext()
在图中创建一个边的全文索引。
参数
schemaName: String
:Schema名称。propertyName: String
:属性名称。indexName: String
:全文索引名称。config: RequestConfig
(可选):请求配置。
返回值
JobResponse
:请求结果。
// Creates a full-text index 'agreeNotes' for the property 'notes' of the 'agree' edges
RequestConfig requestConfig = new RequestConfig();
requestConfig.setGraph("miniCircle");
JobResponse response = driver.createEdgeFulltext("agree", "notes", "agreeNotes", requestConfig);
String jobID = response.getJobId();
Thread.sleep(3000);
List<Job> jobs = driver.showJob(jobID, requestConfig);
for (Job job : jobs) {
System.out.println(job.getId() + " - " + job.getStatus());
}
69 - FINISHED
69_1 - FINISHED
69_2 - FINISHED
69_3 - FINISHED
dropFulltext()
从图中删除一个指定的全文索引。
参数
dbType: DBType
:全文索引类型(点或边)。fulltextName: String
:全文索引名称。config: RequestConfig
(可选):请求配置。
返回值
Response
:请求结果。
// Drops the node full-index 'moviePlot' from the graph 'miniCircle'
RequestConfig requestConfig = new RequestConfig();
requestConfig.setGraph("miniCircle");
Response response = driver.dropFulltext(Ultipa.DBType.DBNODE, "moviePlot", requestConfig);
System.out.println(response.getStatus().getCode());
SUCCESS
LTE
lte()
将一个属性加载到计算引擎。
参数
dbType: DBType
:属性类型(点或边)。schemaName: String
(可选):schema名称;忽略时指定全部schema。propertyName: String
:属性名称。config: RequestConfig
(可选):请求配置。
返回值
JobResponse
:请求结果。
// Loads the property 'year' of 'account' nodes to the computing engine
RequestConfig requestConfig = new RequestConfig();
requestConfig.setGraph("miniCircle");
JobResponse response = driver.lte(Ultipa.DBType.DBNODE, "account", "year", requestConfig);
String jobID = response.getJobId();
Thread.sleep(3000);
List<Job> jobs = driver.showJob(jobID, requestConfig);
for (Job job : jobs) {
System.out.println(job.getId() + " - " + job.getStatus());
}
53 - FINISHED
53_1 - FINISHED
53_2 - FINISHED
53_3 - FINISHED
ufe()
将一个属性从计算引擎卸载。
参数
dbType: DBType
:属性类型(点或边)。schemaName: String
(可选):schema名称;忽略时指定全部schema。propertyName: String
:属性名称。config: RequestConfig
(可选):请求配置。
返回值
Response
:请求结果。
// Unloads the property 'year' of 'account' nodes from the computing engine
RequestConfig requestConfig = new RequestConfig();
requestConfig.setGraph("miniCircle");
Response response = driver.ufe(Ultipa.DBType.DBNODE, "account", "year", requestConfig);
System.out.println(response.getStatus().getCode());
SUCCESS
完整示例
package com.ultipa.www.sdk.api;
import com.google.common.collect.Lists;
import com.ultipa.sdk.UltipaDriver;
import com.ultipa.sdk.connect.conf.RequestConfig;
import com.ultipa.sdk.connect.conf.UltipaConfig;
import com.ultipa.sdk.operate.entity.*;
import java.util.*;
public class Main {
public static void main(String[] args) {
UltipaConfig ultipaConfig = UltipaConfig.config()
// URI example: .hosts(Lists.newArrayList("d3026ac361964633986849ec43b84877s.eu-south-1.cloud.ultipa.com:8443"))
.hosts(Lists.newArrayList("192.168.1.85:60061","192.168.1.88:60061","192.168.1.87:60061"))
.username("<username>")
.password("<password>");
UltipaDriver driver = null;
try {
driver = new UltipaDriver(ultipaConfig);
// Retrieves indexes in the graph 'miniCircle'
RequestConfig requestConfig = new RequestConfig();
requestConfig.setGraph("miniCircle");
List<Index> indexList = driver.showIndex(requestConfig);
for (Index index : indexList) {
System.out.println(index);
}
} catch (InterruptedException e) {
throw new RuntimeException(e);
} finally {
if (driver != null) {
driver.close();
}
}
}
}