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
List<Index>
: The list of retrieved indexes.
// 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()
Retrieves all node indexes from the graph.
Parameters
config: RequestConfig
(Optional): Request configuration.
Returns
List<Index>
: The list of retrieved indexes.
// 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()
Retrieves all edge indexes from the graph.
Parameters
config: RequestConfig
(Optional): Request configuration.
Returns
List<Index>
: The list of retrieved indexes.
// 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()
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'
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()
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'
RequestConfig requestConfig = new RequestConfig();
requestConfig.setGraph("miniCircle");
Response response = driver.dropNodeIndex("test_index", requestConfig);
System.out.println(response.getStatus().getCode());
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'
RequestConfig requestConfig = new RequestConfig();
requestConfig.setGraph("miniCircle");
Response response = driver.dropEdgeIndex("targetPostInd", requestConfig);
System.out.println(response.getStatus().getCode());
SUCCESS
Full-text
showFulltext()
Retrieves all full-text indexes of node and edge properties from the current graphset.
Parameters:
RequestConfig
(Optional): Configuration settings for the request.
Returns:
List<Index>
: The list of all full-text indexes retrieved in the current graphset.
// Retrieves the first full-text index returned in graphset 'miniCircle' and prints its information
RequestConfig requestConfig = new RequestConfig();
requestConfig.setGraphName("miniCircle");
List<Index> indexList = client.showFulltext(requestConfig);
System.out.println(new Gson().toJson(indexList.get(0)));
{"name":"genreFull","properties":"genre","schema":"movie","status":"done"}
showNodeFulltext()
Retrieves all full-text indexes of node properties from the current graphset.
Parameters:
RequestConfig
(Optional): Configuration settings for the request.
Returns:
List<Index>
: The list of all node full-text indexes retrieved in the current graphset.
// Retrieves the first node full-text index returned in graphset 'miniCircle' and prints its information
RequestConfig requestConfig = new RequestConfig();
requestConfig.setGraphName("miniCircle");
List<Index> indexList = client.showNodeFulltext(requestConfig);
System.out.println(new Gson().toJson(indexList.get(0)));
{"name":"genreFull","properties":"genre","schema":"movie","status":"done"}
showEdgeFulltext()
Retrieves all full-text indexes of edge properties from the current graphset.
Parameters:
RequestConfig
(Optional): Configuration settings for the request.
Returns:
List<Index>
: The list of all edge full-text indexes retrieved in the current graphset.
// Retrieves the first edge full-text index returned in graphset 'miniCircle' and prints its information
RequestConfig requestConfig = new RequestConfig();
requestConfig.setGraphName("miniCircle");
List<Index> indexList = client.showEdgeFulltext(requestConfig);
System.out.println(new Gson().toJson(indexList.get(0)));
{"name":"contentFull","properties":"content","schema":"review","status":"done"}
createFulltext()
Creates a new full-text index in the current graphset.
Parameters:
DBType
: Type of the property (node or edge).String
: Name of the schema.String
: Name of the property.String
: Name of the full-text index.RequestConfig
(Optional): Configuration settings for the request.
Returns:
Response
: Result of the request.
// Creates full-text index called 'movieName' for the property @movie.name in graphset 'miniCircle' and prints the error code
RequestConfig requestConfig = new RequestConfig();
requestConfig.setGraphName("miniCircle");
Response response = client.createFulltext(Ultipa.DBType.DBNODE, "movie", "name", "movieName", requestConfig);
System.out.println(response.getStatus().getErrorCode());
SUCCESS
dropFulltext()
Drops a full-text index in the current graphset.
Parameters:
DBType
: Type of the property (node or edge).String
: Name of the full-text index.RequestConfig
(Optional): Configuration settings for the request.
Returns:
Response
: Result of the request.
// Drops the node full-index 'movieName' in graphset 'miniCircle' and prints the error code
RequestConfig requestConfig = new RequestConfig();
requestConfig.setGraphName("miniCircle");
Response response = client.dropFulltext(Ultipa.DBType.DBNODE, "movieName", requestConfig);
System.out.println(response.getStatus().getErrorCode());
SUCCESS
Full Example
package com.ultipa.www.sdk.api;
import com.google.gson.Gson;
import com.ultipa.sdk.connect.Connection;
import com.ultipa.sdk.connect.conf.RequestConfig;
import com.ultipa.sdk.connect.conf.UltipaConfiguration;
import com.ultipa.sdk.connect.driver.UltipaClientDriver;
import com.ultipa.sdk.operate.entity.Index;
import java.util.List;
public class Main {
public static void main(String[] args) {
// Connection configurations
UltipaConfiguration myConfig = UltipaConfiguration.config()
// URI example: .hosts("mqj4zouys.us-east-1.cloud.ultipa.com:60010")
.hosts("192.168.1.85:60611,192.168.1.87:60611,192.168.1.88:60611")
.username("<username>")
.password("<password>");
UltipaClientDriver driver = null;
try {
// Establishes connection to the database
driver = new UltipaClientDriver(myConfig);
Connection client = driver.getConnection();
Thread.sleep(3000);
// Request configurations
RequestConfig requestConfig = new RequestConfig();
requestConfig.setGraphName("Ad_Click");
requestConfig.setUseMaster(true);
// Retrieves all indexes in graphset 'Ad_Click' and prints their information
List<Index> indexList = client.showIndex(requestConfig);
for (Index index : indexList) {
System.out.println(new Gson().toJson(index));
}
} catch (InterruptedException e) {
throw new RuntimeException(e);
} finally {
if (driver != null) {
driver.close();
}
}
}
}