Index table actions

更新时间:
复制 MD 格式

Learn how to use the Java, Python, and Go SDKs to manage index tables.

Dependencies

Java

<dependency>
    <groupId>com.aliyun</groupId>
    <artifactId>aliyun-sdk-ha3engine-vector</artifactId>
    <version>1.1.17</version>
</dependency>

Python

# Requires: Python >=3.6
pip install alibabacloud_ha3engine_vector==1.1.17

Go

go get github.com/aliyun/alibabacloud-ha3-go-sdk@v1.1.17-vector

Parameters

Configure the following four required parameters for the Java and Python SDKs: endpoint, instance_id, access_user_name, and access_pass_word.

  • endpoint: A private or public domain name.

You can find the network information and API endpoint on the instance details page.

After you enable public access, you can call the instance from your local environment using the public endpoint. To configure the IP address whitelist, see Add to whitelist.

To access an ECS instance via its API domain name, configure the instance to use the same switch.

  • instance_id: The instance ID, found at the top of the instance details page.

  • access_user_name: username

  • access_pass_word: password

You can find the username and password in the API endpoint section on the instance details page. This password was set when you purchased the instance and can be changed later.

Index tables

You can call the API by using the OpenAPI Portal.

Java

import com.aliyun.ha3engine.vector.Client;
import com.aliyun.ha3engine.vector.models.Config;
import com.aliyun.ha3engine.vector.models.ListTablesResponse;
import com.aliyun.tea.TeaException;
import org.junit.Before;
import org.junit.Test;
public class ListTables {
    /**
     * The Alibaba Cloud OpenSearch client.
     */
    private static Client client;
    @Before
    public void initClient() throws Exception {
        Config config = new Config();
        // The username. Find it in the API endpoint section on the instance details page.
        config.setAccessUserName("username");
        // The password. You can modify it in the API endpoint section on the instance details page.
        config.setAccessPassWord("password");
        // The API endpoint. Find it in the API endpoint section on the instance details page.
        config.setEndpoint("http://ha-cn-i7*****605.public.ha.aliyuncs.com");
        client = new Client(config);
    }
    /**
     * Lists all tables in the instance.
     * @throws Exception if the request fails.
     */
    @Test
    public void listTables() throws Exception {
        try {
            ListTablesResponse response = client.listTables();
            System.out.println(com.aliyun.teautil.Common.toJSONString(response.getBody()));
        } catch (TeaException e) {
            System.out.println(e.getCode());
            System.out.println(e.getMessage());
        }
    }
}

Python

from alibabacloud_ha3engine_vector.client import Client
from alibabacloud_ha3engine_vector.models import Config
config = Config(
    # The API endpoint. Find it in the API endpoint section on the instance details page.
    endpoint="http://ha-cn-i7*****605.public.ha.aliyuncs.com",
    # The username. Find it in the API endpoint section on the instance details page.
    access_user_name="username",
    # The password. You can modify it in the API endpoint section on the instance details page.
    access_pass_word="password")
client = Client(config)
def list_tables():
    result = client.list_tables()
    print(result.body)
if __name__ == "__main__":
    list_tables()

Go

package main
import (
    "fmt"
    "github.com/alibabacloud-go/tea/tea"
    ha3engine "github.com/aliyun/alibabacloud-ha3-go-sdk/client"
)
func main() {
    config := &ha3engine.Config{
		// The API endpoint. Find it in the API endpoint section on the instance details page.
		Endpoint: tea.String("http://ha-cn-i7*****605.public.ha.aliyuncs.com"),
		// The username. Find it in the API endpoint section on the instance details page.
		AccessUserName: tea.String("username"),
		// The password. You can modify it in the API endpoint section on the instance details page.
		AccessPassWord: tea.String("password"),
	}
    // Create the client.
    client, _clientErr := ha3engine.NewClient(config)
    // If client creation fails, print the error and exit.
    if _clientErr != nil {
        fmt.Println(_clientErr)
        return
    }
    listTables(client)
}
func listTables(client *ha3engine.Client) {
    response, _requestErr := client.ListTables()
    // If the request fails, print the error and return.
    if _requestErr != nil {
        fmt.Println(_requestErr)
        return
    }
    // Print the response body.
    fmt.Println(response.Body)
}

Index table

You can call APIs from the OpenAPI Portal.

Java

import com.aliyun.ha3engine.vector.Client;
import com.aliyun.ha3engine.vector.models.Config;
import com.aliyun.ha3engine.vector.models.GetTableResponse;
import com.aliyun.tea.TeaException;
import org.junit.Before;
import org.junit.Test;
public class GetTable {
    /**
     * The HA3 Engine client.
     */
    private static Client client;
    @Before
    public void initClient() throws Exception {
        Config config = new Config();
        // Your username. You can find this on the Instance Details page in the API Endpoint section.
        config.setAccessUserName("username");
        // Your password. You can change this on the Instance Details page in the API Endpoint section.
        config.setAccessPassWord("password");
        // The API endpoint for your instance. You can find this on the Instance Details page in the API Endpoint section.
        config.setEndpoint("http://ha-cn-i7*****605.public.ha.aliyuncs.com");
        client = new Client(config);
    }
    /**
     * Retrieves the details of an index table.
     * @throws Exception
     */
    @Test
    public void getTable() throws Exception {
        try {
            // The table name.
            String tableName = "test";
            GetTableResponse response = client.getTable(tableName);
            System.out.println(com.aliyun.teautil.Common.toJSONString(response.getBody()));
        } catch (TeaException e) {
            System.out.println(e.getCode());
            System.out.println(e.getMessage());
        }
    }
}

Python

from alibabacloud_ha3engine_vector.client import Client
from alibabacloud_ha3engine_vector.models import Config
config = Config(
    # The API endpoint for your instance. You can find this on the Instance Details page in the API Endpoint section.
    endpoint="http://ha-cn-i7*****605.public.ha.aliyuncs.com",
    # Your username. You can find this on the Instance Details page in the API Endpoint section.
    access_user_name="username",
    # Your password. You can change this on the Instance Details page in the API Endpoint section.
    access_pass_word="password")
client = Client(config)
def get_table(table_name: str):
    result = client.get_table(table_name)
    print(result.body)
if __name__ == "__main__":
    get_table("test_api")

Go

package main
import (
	"fmt"
	"github.com/alibabacloud-go/tea/tea"
	ha3engine "github.com/aliyun/alibabacloud-ha3-go-sdk/client"
)
func main() {
	config := &ha3engine.Config{
		// The API endpoint for your instance. You can find this on the Instance Details page in the API Endpoint section.
		Endpoint: tea.String("http://ha-cn-i7*****605.public.ha.aliyuncs.com"),
		// Your username. You can find this on the Instance Details page in the API Endpoint section.
		AccessUserName: tea.String("username"),
		// Your password. You can change this on the Instance Details page in the API Endpoint section.
		AccessPassWord: tea.String("password"),
	}
	// Create the client.
	client, _clientErr := ha3engine.NewClient(config)
	// If client creation fails, print the error and exit.
	if _clientErr != nil {
		fmt.Println(_clientErr)
		return
	}
	getTable(client)
}
func getTable(client *ha3engine.Client) {
	response, _requestErr := client.GetTable(tea.String("test_api"))
	// If the request fails, print the error and exit.
	if _requestErr != nil {
		fmt.Println(_requestErr)
		return
	}
	// Print the response body.
	fmt.Println(response.Body)
}

Index table

You can call this operation in OpenAPI Explorer.

API

Java

import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import com.aliyun.ha3engine.vector.Client;
import com.aliyun.ha3engine.vector.models.Config;
import com.aliyun.ha3engine.vector.models.CreateTableRequest;
import com.aliyun.ha3engine.vector.models.CreateTableResponse;
import com.aliyun.tea.TeaException;
import com.aliyun.teautil.models.RuntimeOptions;
import org.junit.Before;
import org.junit.Test;
public class CreateTable {
    /**
     * The Havenask client.
     */
    private static Client client;
    @Before
    public void initClient() throws Exception {
        Config config = new Config();
        // The username. You can find it on the Instance Details page in the API Endpoint section.
        config.setAccessUserName("username");
        // The password. You can change it on the Instance Details page in the API Endpoint section.
        config.setAccessPassWord("password");
        // The API endpoint. You can find it on the Instance Details page in the API Endpoint section.
        config.setEndpoint("http://ha-cn-i7*****605.public.ha.aliyuncs.com");
        RuntimeOptions runtimeOptions = new RuntimeOptions();
        runtimeOptions.setConnectTimeout(10000);
        runtimeOptions.setReadTimeout(10000);
        config.setRuntimeOptions(runtimeOptions);
        client = new Client(config);
    }
    /**
     * Creates a table that uses the API as the default data source.
     * @throws Exception
     */
    @Test
    public void createTable() throws Exception {
        try {
            // The request parameters.
            CreateTableRequest request = new CreateTableRequest();
            // The table name.
            request.setName("test_api");
            // The primary key.
            request.setPrimaryKey("id");
            // The number of data shards.
            request.setPartitionCount(1);
            // The field schema.
            Map<String, String> fieldSchema = new HashMap<String, String>(){{
                put("id", "STRING");
                put("name", "STRING");
                put("vector", "MULTI_FLOAT");
            }};
            request.setFieldSchema(fieldSchema);
            // The vector index configuration.
            CreateTableRequest.CreateTableRequestVectorIndex vectorIndex = new CreateTableRequest.CreateTableRequestVectorIndex();
            // The vector index name.
            vectorIndex.setIndexName("vector");
            // The vector field.
            vectorIndex.setVectorField("vector");
            // The vector dimension.
            vectorIndex.setDimension("2");
            // The vector index algorithm.
            vectorIndex.setVectorIndexType("Qc");
            // The distance metric for the vector index.
            vectorIndex.setDistanceType("InnerProduct");
            request.setVectorIndex(Collections.singletonList(vectorIndex));
            // Specifies whether to perform only a dry run.
            request.setDryRun(false);
            CreateTableResponse response = client.createTable(request);
            System.out.println(com.aliyun.teautil.Common.toJSONString(response.getBody()));
        } catch (TeaException e) {
            System.out.println(e.getCode());
            System.out.println(e.getMessage());
        }
    }

Python

from alibabacloud_ha3engine_vector.client import Client
from alibabacloud_ha3engine_vector.models import Config, CreateTableRequest, CreateTableRequestVectorIndex
config = Config(
    # The API endpoint. You can find it on the Instance Details page in the API Endpoint section.
    endpoint="http://ha-cn-i7*****605.public.ha.aliyuncs.com",
    # The username. You can find it on the Instance Details page in the API Endpoint section.
    access_user_name="username",
    # The password. You can change it on the Instance Details page in the API Endpoint section.
    access_pass_word="password")
client = Client(config)
def create_table():
    # The request parameters.
    request = CreateTableRequest()
    # The table name.
    request.name = "test_api"
    # The primary key.
    request.primary_key = "id"
    # The number of data shards.
    request.partition_count = 1
    # The field schema.
    request.field_schema = {
        "id": "STRING",
        "vector": "MULTI_FLOAT",
        "name": "STRING"
    }
    # The vector index configuration.
    vector_index = CreateTableRequestVectorIndex()
    # The vector index name.
    vector_index.index_name = "vector"
    # The vector field.
    vector_index.vector_field = "vector"
    # The vector dimension.
    vector_index.dimension = 2
    # The vector index algorithm.
    vector_index.vector_index_type = "Qc"
    # The distance metric for the vector index.
    vector_index.distance_type = "InnerProduct"
    request.vector_index = [vector_index]
    result = client.create_table(request)
    print(result.body)
if __name__ == "__main__":
    create_table()

Go

package main
import (
	"fmt"
	"github.com/alibabacloud-go/tea/tea"
	ha3engine "github.com/aliyun/alibabacloud-ha3-go-sdk/client"
)
func main() {
	// Define the client configuration.
	config := &ha3engine.Config{
		// The API endpoint. You can find it on the Instance Details page in the API Endpoint section.
		Endpoint: tea.String("http://ha-cn-i7*****605.public.ha.aliyuncs.com"),
		// The username. You can find it on the Instance Details page in the API Endpoint section.
		AccessUserName: tea.String("username"),
		// The password. You can change it on the Instance Details page in the API Endpoint section.
		AccessPassWord: tea.String("password"),
	}
	// Create a client to send requests.
	client, _clientErr := ha3engine.NewClient(config)
	// If an error occurs during client creation, print the error and exit.
	if _clientErr != nil {
		fmt.Println(_clientErr)
		return
	}
	createTable(client)
}
func createTable(client *ha3engine.Client) {
	// The request parameters.
	request := &ha3engine.CreateTableRequest{
		// The table name.
		Name: tea.String("test_api"),
		// The primary key.
		PrimaryKey: tea.String("id"),
		// The number of data shards.
		PartitionCount: tea.Int32(1),
	}
	// The field schema.
	fieldSchema := map[string]*string{
		"id":     tea.String("STRING"),
		"name":   tea.String("STRING"),
		"vector": tea.String("MULTI_FLOAT"),
	}
	request.FieldSchema = fieldSchema
	// The vector index configuration.
	vectorIndex := &ha3engine.CreateTableRequestVectorIndex{
		// The vector index name.
		IndexName: tea.String("vector"),
		// The vector field.
		VectorField: tea.String("vector"),
		// The vector dimension.
		Dimension: tea.String("2"),
		// The vector index algorithm.
		VectorIndexType: tea.String("Qc"),
		// The distance metric for the vector index.
		DistanceType: tea.String("InnerProduct"),
	}
	request.VectorIndex = []*ha3engine.CreateTableRequestVectorIndex{vectorIndex}
	response, _requestErr := client.CreateTable(request)
	// If an error occurs while sending the request, print the error and exit.
	if _requestErr != nil {
		fmt.Println(_requestErr)
		return
	}
	// Print the response.
	fmt.Println(response.Body)
}

Data source: OSS

Java

import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import com.aliyun.ha3engine.vector.Client;
import com.aliyun.ha3engine.vector.models.Config;
import com.aliyun.ha3engine.vector.models.CreateTableRequest;
import com.aliyun.ha3engine.vector.models.CreateTableResponse;
import com.aliyun.tea.TeaException;
import com.aliyun.teautil.models.RuntimeOptions;
import org.junit.Before;
import org.junit.Test;
public class CreateTable {
    /**
     * The OpenSearch client.
     */
    private static Client client;
    @Before
    public void initClient() throws Exception {
        Config config = new Config();
        // Your username. Find it on the Instance Details page in the API Endpoint section.
        config.setAccessUserName("username");
        // Your password. Change it on the Instance Details page in the API Endpoint section.
        config.setAccessPassWord("password");
        // The API endpoint for your instance. Find it on the Instance Details page in the API Endpoint section.
        config.setEndpoint("http://ha-cn-i7*****605.public.ha.aliyuncs.com");
        RuntimeOptions runtimeOptions = new RuntimeOptions();
        runtimeOptions.setConnectTimeout(10000);
        runtimeOptions.setReadTimeout(10000);
        config.setRuntimeOptions(runtimeOptions);
        client = new Client(config);
    }
    /**
     * Creates a table with OSS as the data source.
     * @throws Exception
     */
    @Test
    public void createOssTable() throws Exception {
        try {
            // Request parameters.
            CreateTableRequest request = new CreateTableRequest();
            // The table name.
            request.setName("test_oss");
            // The primary key.
            request.setPrimaryKey("id");
            // The number of data shards.
            request.setPartitionCount(1);
            // Field configuration.
            Map<String, String> fieldSchema = new HashMap<String, String>(){{
                put("id", "STRING");
                put("name", "STRING");
                put("vector", "MULTI_FLOAT");
            }};
            request.setFieldSchema(fieldSchema);
            // Vector index configuration.
            CreateTableRequest.CreateTableRequestVectorIndex vectorIndex = new CreateTableRequest.CreateTableRequestVectorIndex();
            // The name of the vector index.
            vectorIndex.setIndexName("vector");
            // The vector field to index.
            vectorIndex.setVectorField("vector");
            // The dimension of the vectors.
            vectorIndex.setDimension("2");
            // The algorithm for the vector index.
            vectorIndex.setVectorIndexType("Qc");
            // The distance type for similarity search.
            vectorIndex.setDistanceType("InnerProduct");
            request.setVectorIndex(Collections.singletonList(vectorIndex));
            // Data source configuration.
            CreateTableRequest.CreateTableRequestDataSource dataSource = new CreateTableRequest.CreateTableRequestDataSource();
            // The type of the data source.
            dataSource.setType("oss");
            CreateTableRequest.CreateTableRequestDataSourceConfig config = new CreateTableRequest.CreateTableRequestDataSourceConfig();
            // The path to your data file in the OSS bucket.
            config.setOssPath("<oss_path>");
            // The name of the OSS bucket.
            config.setBucket("<oss_bucket_name>");
            // The endpoint for OSS. This is required to validate that the bucket is in the same region as your OpenSearch instance.
            config.setEndpoint("<oss_endpoint>");
            dataSource.setConfig(config);
            request.setDataSource(dataSource);
            // Specifies whether to perform a dry run.
            request.setDryRun(false);
            CreateTableResponse response = client.createTable(request);
            System.out.println(com.aliyun.teautil.Common.toJSONString(response.getBody()));
        } catch (TeaException e) {
            System.out.println(e.getCode());
            System.out.println(e.getMessage());
        }
    }

Python

from alibabacloud_ha3engine_vector.client import Client
from alibabacloud_ha3engine_vector.models import Config, CreateTableRequest, CreateTableRequestVectorIndex, CreateTableRequestDataSource, CreateTableRequestDataSourceConfig
config = Config(
    # The API endpoint for your instance. Find it on the Instance Details page in the API Endpoint section.
    endpoint="http://ha-cn-i7*****605.public.ha.aliyuncs.com",
    # Your username. Find it on the Instance Details page in the API Endpoint section.
    access_user_name="username",
    # Your password. Change it on the Instance Details page in the API Endpoint section.
    access_pass_word="password")
client = Client(config)
def create_oss_table():
    # Request parameters.
    request = CreateTableRequest()
    # The table name.
    request.name = "test_oss"
    # The primary key.
    request.primary_key = "id"
    # The number of data shards.
    request.partition_count = 1
    # Field configuration.
    request.field_schema = {
        "id": "STRING",
        "vector": "MULTI_FLOAT",
        "name": "STRING"
    }
    # Vector index configuration.
    vector_index = CreateTableRequestVectorIndex()
    # The name of the vector index.
    vector_index.index_name = "vector"
    # The vector field to index.
    vector_index.vector_field = "vector"
    # The dimension of the vectors.
    vector_index.dimension = "2"
    # The algorithm for the vector index.
    vector_index.vector_index_type = "Qc"
    # The distance type for similarity search.
    vector_index.distance_type = "InnerProduct"
    request.vector_index = [vector_index]
    # Data source configuration.
    data_source = CreateTableRequestDataSource()
    # The type of the data source.
    data_source.type = "oss"
    config = CreateTableRequestDataSourceConfig()
    # The path to your data file in the OSS bucket.
    config.oss_path = "<oss_path>"
    # The name of the OSS bucket.
    config.bucket = "<oss_bucket_name>"
    # The endpoint for OSS. This is required to validate that the bucket is in the same region as your OpenSearch instance.
    config.endpoint = "<oss_endpoint>"
    data_source.config = config
    request.data_source = data_source
    result = client.create_table(request)
    print(result.body)
if __name__ == "__main__":
    create_oss_table()

Go

package main
import (
	"fmt"
	"github.com/alibabacloud-go/tea/tea"
	ha3engine "github.com/aliyun/alibabacloud-ha3-go-sdk/client"
)
func main() {
	// Create a client instance.
	config := &ha3engine.Config{
		// The API endpoint for your instance. Find it on the Instance Details page in the API Endpoint section.
		Endpoint: tea.String("http://ha-cn-i7*****605.public.ha.aliyuncs.com"),
		// Your username. Find it on the Instance Details page in the API Endpoint section.
		AccessUserName: tea.String("username"),
		// Your password. Change it on the Instance Details page in the API Endpoint section.
		AccessPassWord: tea.String("password"),
	}
	// Create the client.
	client, _clientErr := ha3engine.NewClient(config)
	// Print the error and exit if client initialization fails.
	if _clientErr != nil {
		fmt.Println(_clientErr)
		return
	}
	createOssTable(client)
}
func createOssTable(client *ha3engine.Client) {
	// Request parameters.
	request := &ha3engine.CreateTableRequest{
		// The table name.
		Name: tea.String("test_oss"),
		// The primary key.
		PrimaryKey: tea.String("id"),
		// The number of data shards.
		PartitionCount: tea.Int32(1),
	}
	// Field configuration.
	fieldSchema := map[string]*string{
		"id":     tea.String("STRING"),
		"name":   tea.String("STRING"),
		"vector": tea.String("MULTI_FLOAT"),
	}
	request.FieldSchema = fieldSchema
	// Vector index configuration.
	vectorIndex := &ha3engine.CreateTableRequestVectorIndex{
		// The name of the vector index.
		IndexName: tea.String("vector"),
		// The vector field to index.
		VectorField: tea.String("vector"),
		// The dimension of the vectors.
		Dimension: tea.String("2"),
		// The algorithm for the vector index.
		VectorIndexType: tea.String("Qc"),
		// The distance type for similarity search.
		DistanceType: tea.String("InnerProduct"),
	}
	request.VectorIndex = []*ha3engine.CreateTableRequestVectorIndex{vectorIndex}
	// Data source configuration.
	config := &ha3engine.CreateTableRequestDataSourceConfig{
		// The path to your data file in the OSS bucket.
		OssPath: tea.String("<oss_path>"),
		// The name of the OSS bucket.
		Bucket: tea.String("<oss_bucket_name>"),
		// The endpoint for OSS. This is required to validate that the bucket is in the same region as your OpenSearch instance.
		Endpoint: tea.String("<oss_endpoint>"),
	}
	dataSource := &ha3engine.CreateTableRequestDataSource{
		// The type of the data source.
		Type:   tea.String("oss"),
		Config: config,
	}
	request.DataSource = dataSource
	response, _requestErr := client.CreateTable(request)
	// Print the error and exit if the request fails.
	if _requestErr != nil {
		fmt.Println(_requestErr)
		return
	}
	// Print the response body.
	fmt.Println(response.Body)
}

MaxCompute

Java

import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import com.aliyun.ha3engine.vector.Client;
import com.aliyun.ha3engine.vector.models.Config;
import com.aliyun.ha3engine.vector.models.CreateTableRequest;
import com.aliyun.ha3engine.vector.models.CreateTableResponse;
import com.aliyun.tea.TeaException;
import com.aliyun.teautil.models.RuntimeOptions;
import org.junit.Before;
import org.junit.Test;
public class CreateTable {
    /**
     * The ha3engine client.
     */
    private static Client client;
    @Before
    public void initClient() throws Exception {
        Config config = new Config();
        // Username. You can find this on the instance details page in the API endpoint section.
        config.setAccessUserName("username");
        // Password. You can change this on the instance details page in the API endpoint section.
        config.setAccessPassWord("password");
        // API endpoint. You can find this on the instance details page.
        config.setEndpoint("http://ha-cn-i7*****605.public.ha.aliyuncs.com");
        RuntimeOptions runtimeOptions = new RuntimeOptions();
        runtimeOptions.setConnectTimeout(10000);
        runtimeOptions.setReadTimeout(10000);
        config.setRuntimeOptions(runtimeOptions);
        client = new Client(config);
    }
    /**
     * Creates a table with MaxCompute as the data source.
     * @throws Exception
     */
    @Test
    public void createMaxComputeTable() throws Exception {
        try {
            // Request parameters.
            CreateTableRequest request = new CreateTableRequest();
            // Table name.
            request.setName("test_odps");
            // Primary key.
            request.setPrimaryKey("id");
            // Number of data shards.
            request.setPartitionCount(1);
            // Field configuration.
            Map<String, String> fieldSchema = new HashMap<String, String>(){{
                put("id", "STRING");
                put("name", "STRING");
                put("vector", "MULTI_FLOAT");
            }};
            request.setFieldSchema(fieldSchema);
            // Vector index configuration.
            CreateTableRequest.CreateTableRequestVectorIndex vectorIndex = new CreateTableRequest.CreateTableRequestVectorIndex();
            // Vector index name.
            vectorIndex.setIndexName("vector");
            // Vector field.
            vectorIndex.setVectorField("vector");
            // Vector dimension.
            vectorIndex.setDimension("2");
            // Vector index algorithm.
            vectorIndex.setVectorIndexType("Qc");
            // Vector index distance type.
            vectorIndex.setDistanceType("InnerProduct");
            request.setVectorIndex(Collections.singletonList(vectorIndex));
            // Data source configuration.
            CreateTableRequest.CreateTableRequestDataSource dataSource = new CreateTableRequest.CreateTableRequestDataSource();
            // Data source type.
            dataSource.setType("odps");
            CreateTableRequest.CreateTableRequestDataSourceConfig config = new CreateTableRequest.CreateTableRequestDataSourceConfig();
            // AccessKey. Required. Ensure the ALIBABA_CLOUD_ACCESS_KEY_ID environment variable is set.
            config.setAccessKey(System.getenv("ALIBABA_CLOUD_ACCESS_KEY_ID"));
            // AccessSecret. Required. Ensure the ALIBABA_CLOUD_ACCESS_KEY_SECRET environment variable is set.
            config.setAccessSecret(System.getenv("ALIBABA_CLOUD_ACCESS_KEY_SECRET"));
            // MaxCompute project name.
            config.setProject("<odps_project_name>");
            // MaxCompute table name.
            config.setTable("<odps_table_name>");
            // MaxCompute table partition.
            config.setPartition("<odps_partition>");
            dataSource.setConfig(config);
            request.setDataSource(dataSource);
            // Specifies whether to perform a dry run.
            request.setDryRun(false);
            CreateTableResponse response = client.createTable(request);
            System.out.println(com.aliyun.teautil.Common.toJSONString(response.getBody()));
        } catch (TeaException e) {
            System.out.println(e.getCode());
            System.out.println(e.getMessage());
        }
    }
}

Python

from alibabacloud_ha3engine_vector.client import Client
from alibabacloud_ha3engine_vector.models import Config, CreateTableRequest, CreateTableRequestVectorIndex, CreateTableRequestDataSource, CreateTableRequestDataSourceConfig
config = Config(
    # API endpoint. You can find this on the instance details page.
    endpoint="http://ha-cn-i7*****605.public.ha.aliyuncs.com",
    # Username. You can find this on the instance details page in the API endpoint section.
    access_user_name="username",
    # Password. You can change this on the instance details page in the API endpoint section.
    access_pass_word="password")
client = Client(config)
def create_odps_table():
    # Request parameters.
    request = CreateTableRequest()
    # Table name.
    request.name = "test_odps1"
    # Primary key.
    request.primary_key = "id"
    # Number of data shards.
    request.partition_count = 1
    # Field configuration.
    request.field_schema = {
        "id": "INT32",
        "vector": "MULTI_FLOAT",
        "name": "STRING"
    }
    # Vector index configuration.
    vector_index = CreateTableRequestVectorIndex()
    # Vector index name.
    vector_index.index_name = "vector"
    # Vector field.
    vector_index.vector_field = "vector"
    # Vector dimension.
    vector_index.dimension = 2
    # Vector index algorithm.
    vector_index.vector_index_type = "HNSW"
    # Vector index distance type.
    vector_index.distance_type = "InnerProduct"
    request.vector_index = [vector_index]
    # Data source configuration.
    data_source = CreateTableRequestDataSource()
    # Data source type.
    data_source.type = "odps"
    config = CreateTableRequestDataSourceConfig()
    # AccessKey. Required. Ensure the ALIBABA_CLOUD_ACCESS_KEY_ID environment variable is set.
    config.access_key = os.getenv("ALIBABA_CLOUD_ACCESS_KEY_ID")
    # AccessSecret. Required. Ensure the ALIBABA_CLOUD_ACCESS_KEY_SECRET environment variable is set.
    config.access_secret = os.getenv("ALIBABA_CLOUD_ACCESS_KEY_SECRET")
    # MaxCompute project name.
    config.project = "<odps_project_name>"
    # MaxCompute table name.
    config.table = "<odps_table_name>"
    # MaxCompute table partition.
    config.partition = "<odps_partition>"
    data_source.config = config
    request.data_source = data_source
    result = client.create_table(request)
    print(result.body)
if __name__ == "__main__":
    create_odps_table()

Go

package main
import (
	"fmt"
	"github.com/alibabacloud-go/tea/tea"
	ha3engine "github.com/aliyun/alibabacloud-ha3-go-sdk/client"
    "os"
)
func main() {
	// Create a client instance.
	config := &ha3engine.Config{
		// API endpoint. You can find this on the instance details page.
		Endpoint: tea.String("http://ha-cn-i7*****605.public.ha.aliyuncs.com"),
		// Username. You can find this on the instance details page in the API endpoint section.
		AccessUserName: tea.String("username"),
		// Password. You can change this on the instance details page in the API endpoint section.
		AccessPassWord: tea.String("password"),
	}
	// Create a new client.
	client, _clientErr := ha3engine.NewClient(config)
	// Handle client creation errors.
	if _clientErr != nil {
		fmt.Println(_clientErr)
		return
	}
	createOdpsTable(client)
}
func createOdpsTable(client *ha3engine.Client) {
	// Request parameters.
	request := &ha3engine.CreateTableRequest{
		// Table name.
		Name: tea.String("test_odps"),
		// Primary key.
		PrimaryKey: tea.String("id"),
		// Number of data shards.
		PartitionCount: tea.Int32(1),
	}
	// Field configuration.
	fieldSchema := map[string]*string{
		"id":     tea.String("STRING"),
		"name":   tea.String("STRING"),
		"vector": tea.String("MULTI_FLOAT"),
	}
	request.FieldSchema = fieldSchema
	// Vector index configuration.
	vectorIndex := &ha3engine.CreateTableRequestVectorIndex{
		// Vector index name.
		IndexName: tea.String("vector"),
		// Vector field.
		VectorField: tea.String("vector"),
		// Vector dimension.
		Dimension: tea.String("2"),
		// Vector index algorithm.
		VectorIndexType: tea.String("Qc"),
		// Vector index distance type.
		DistanceType: tea.String("InnerProduct"),
	}
	request.VectorIndex = []*ha3engine.CreateTableRequestVectorIndex{vectorIndex}
	// Data source configuration.
	config := &ha3engine.CreateTableRequestDataSourceConfig{
		// AccessKey. Required. Ensure the ALIBABA_CLOUD_ACCESS_KEY_ID environment variable is set.
		AccessKey:    tea.String(os.Getenv("ALIBABA_CLOUD_ACCESS_KEY_ID")),
		// AccessSecret. Required. Ensure the ALIBABA_CLOUD_ACCESS_KEY_SECRET environment variable is set.
		AccessSecret: tea.String(os.Getenv("ALIBABA_CLOUD_ACCESS_KEY_SECRET")),
		// MaxCompute project name.
		Project: tea.String("<odps_project_name>"),
		// MaxCompute table name.
		Table: tea.String("<odps_table_name>"),
		// MaxCompute table partition.
		Partition: tea.String("<odps_partition>"),
	}
	dataSource := &ha3engine.CreateTableRequestDataSource{
		// Data source type.
		Type:   tea.String("odps"),
		Config: config,
	}
	request.DataSource = dataSource
	response, _requestErr := client.CreateTable(request)
	// Handle request errors.
	if _requestErr != nil {
		fmt.Println(_requestErr)
		return
	}
	// Print the response body.
	fmt.Println(response.Body)
}

Edit an index

You can call this operation by using OpenAPI Portal.

Java

import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import com.aliyun.ha3engine.vector.Client;
import com.aliyun.ha3engine.vector.models.*;
import com.aliyun.tea.TeaException;
import org.junit.Before;
import org.junit.Test;
public class ModifyTable {
    /**
     * The Hologres client.
     */
    private static Client client;
    @Before
    public void initClient() throws Exception {
        Config config = new Config();
        // The username. Find it on the Instance Details page > API endpoint.
        config.setAccessUserName("username");
        // The password. You can change it on the Instance Details page > API endpoint.
        config.setAccessPassWord("password");
        // The API endpoint. Find it on the Instance Details page > API endpoint.
        config.setEndpoint("http://ha-cn-i7*****605.public.ha.aliyuncs.com");
        client = new Client(config);
    }
    /**
     * Modify a table.
     * @throws Exception
     */
    @Test
    public void modifyTable() throws Exception {
        try {
            // Request parameters.
            ModifyTableRequest request = new ModifyTableRequest();
            // Primary key.
            request.setPrimaryKey("id");
            // Number of data shards.
            request.setPartitionCount(1);
            // Field configuration.
            Map<String, String> fieldSchema = new HashMap<String, String>(){{
                put("id", "STRING");
                put("name", "STRING");
                put("vector", "MULTI_FLOAT");
                put("age", "INT32");
            }};
            request.setFieldSchema(fieldSchema);
            // Vector index configuration.
            ModifyTableRequest.ModifyTableRequestVectorIndex vectorIndex = new ModifyTableRequest.ModifyTableRequestVectorIndex();
            // Vector index name.
            vectorIndex.setIndexName("vector");
            // Vector field.
            vectorIndex.setVectorField("vector");
            // Vector dimension.
            vectorIndex.setDimension("2");
            // Vector index algorithm.
            vectorIndex.setVectorIndexType("Qc");
            // Vector index distance type.
            vectorIndex.setDistanceType("InnerProduct");
            request.setVectorIndex(Collections.singletonList(vectorIndex));
            ModifyTableResponse response = client.modifyTable("test_api", request);
            System.out.println(com.aliyun.teautil.Common.toJSONString(response.getBody()));
        } catch (TeaException e) {
            System.out.println(e.getCode());
            System.out.println(e.getMessage());
        }
    }
}

Python

from alibabacloud_ha3engine_vector.client import Client
from alibabacloud_ha3engine_vector.models import Config, ModifyTableRequest, ModifyTableRequestVectorIndex
config = Config(
    # The API endpoint. Find it on the Instance Details page > API endpoint.
    endpoint="http://ha-cn-i7*****605.public.ha.aliyuncs.com",
    # The username. Find it on the Instance Details page > API endpoint.
    access_user_name="username",
    # The password. You can change it on the Instance Details page > API endpoint.
    access_pass_word="password")
client = Client(config)
def modify_table():
    # Request parameters.
    request = ModifyTableRequest()
    # request.dry_run = True
    # Primary key.
    request.primary_key = "id"
    # Number of data shards.
    request.partition_count = 1
    # Field configuration.
    request.field_schema = {
        "id": "STRING",
        "vector": "MULTI_FLOAT",
        "name": "STRING",
        "age": "INT32"
    }
    # Vector index configuration.
    vector_index = ModifyTableRequestVectorIndex()
    # Vector index name.
    vector_index.index_name = "vector"
    # Vector field.
    vector_index.vector_field = "vector"
    # Vector dimension.
    vector_index.dimension = 2
    # Vector index algorithm.
    vector_index.vector_index_type = "Qc"
    # Vector index distance type.
    vector_index.distance_type = "InnerProduct"
    request.vector_index = [vector_index]
    result = client.modify_table("test_api", request)
    print(result.body)
if __name__ == "__main__":
    modify_table()

Go

package main
import (
	"fmt"
	"github.com/alibabacloud-go/tea/tea"
	ha3engine "github.com/aliyun/alibabacloud-ha3-go-sdk/client"
)
func main() {
	// Create a client instance.
	config := &ha3engine.Config{
		// The API endpoint. Find it on the Instance Details page > API endpoint.
		Endpoint: tea.String("http://ha-cn-i7*****605.public.ha.aliyuncs.com"),
		// The username. Find it on the Instance Details page > API endpoint.
		AccessUserName: tea.String("username"),
		// The password. You can change it on the Instance Details page > API endpoint.
		AccessPassWord: tea.String("password"),
	}
	// Initialize a client to send requests.
	client, _clientErr := ha3engine.NewClient(config)
	// Handle client initialization errors.
	if _clientErr != nil {
		fmt.Println(_clientErr)
		return
	}
	modifyTable(client)
}
func modifyTable(client *ha3engine.Client) {
	// Request parameters.
	request := &ha3engine.ModifyTableRequest{
		// Primary key.
		PrimaryKey: tea.String("id"),
		// Number of data shards.
		PartitionCount: tea.Int32(1),
	}
	// Field configuration.
	fieldSchema := map[string]*string{
		"id":     tea.String("STRING"),
		"name":   tea.String("STRING"),
		"vector": tea.String("MULTI_FLOAT"),
		"age":    tea.String("INT32"),
	}
	request.FieldSchema = fieldSchema
	// Vector index configuration.
	vectorIndex := &ha3engine.ModifyTableRequestVectorIndex{
		// Vector index name.
		IndexName: tea.String("vector"),
		// Vector field.
		VectorField: tea.String("vector"),
		// Vector dimension.
		Dimension: tea.String("2"),
		// Vector index algorithm.
		VectorIndexType: tea.String("Qc"),
		// Vector index distance type.
		DistanceType: tea.String("InnerProduct"),
	}
	request.VectorIndex = []*ha3engine.ModifyTableRequestVectorIndex{vectorIndex}
	response, _requestErr := client.ModifyTable(tea.String("test_api"), request)
	// Handle request errors.
	if _requestErr != nil {
		fmt.Println(_requestErr)
		return
	}
	// Print the response body.
	fmt.Println(response.Body)
}

Index rebuild

Use the OpenAPI portal to call the API.

Java

import com.aliyun.ha3engine.vector.Client;
import com.aliyun.ha3engine.vector.models.Config;
import com.aliyun.ha3engine.vector.models.ReindexRequest;
import com.aliyun.ha3engine.vector.models.ReindexResponse;
import com.aliyun.tea.TeaException;
import org.junit.Before;
import org.junit.Test;
public class ReIndex {
    /**
     * The client for OpenSearch-LLM Vector Search Edition.
     */
    private static Client client;
    @Before
    public void initClient() throws Exception {
        Config config = new Config();
        // Your username. Find it in the API endpoint section on the instance details page.
        config.setAccessUserName("username");
        // Your password. You can change it in the API endpoint section on the instance details page.
        config.setAccessPassWord("password");
        // The API endpoint for your instance. Find it in the API endpoint section on the instance details page.
        config.setEndpoint("http://ha-cn-i7*****605.public.ha.aliyuncs.com");
        client = new Client(config);
    }
    /**
     * Rebuilds the index.
     * @throws Exception
     */
    @Test
    public void reindex() throws Exception {
        try {
            ReindexRequest request = new ReindexRequest();
            // The timestamp for the data version to be reindexed.
            request.setDataTimeSec(1741231869);
            ReindexResponse response = client.reindex("test_api", request);
            System.out.println(com.aliyun.teautil.Common.toJSONString(response.getBody()));
        } catch (TeaException e) {
            System.out.println(e.getCode());
            System.out.println(e.getMessage());
        }
    }
}

Python

from alibabacloud_ha3engine_vector.client import Client
from alibabacloud_ha3engine_vector.models import Config, ReindexRequest
config = Config(
    # The API endpoint for your instance. Find it in the API endpoint section on the instance details page.
    endpoint="http://ha-cn-i7*****605.public.ha.aliyuncs.com",
    # Your username. Find it in the API endpoint section on the instance details page.
    access_user_name="username",
    # Your password. You can change it in the API endpoint section on the instance details page.
    access_pass_word="password")
client = Client(config)
def reindex(table_name: str):
    request = ReindexRequest()
    # The timestamp for the data version to be reindexed.
    request.data_time_sec = 1741231869
    result = client.reindex(table_name, request)
    print(result.body)
if __name__ == "__main__":
    reindex("test_api")

Go

package main
import (
	"fmt"
	"github.com/alibabacloud-go/tea/tea"
	ha3engine "github.com/aliyun/alibabacloud-ha3-go-sdk/client"
)
func main() {
	// Define the client configuration.
	config := &ha3engine.Config{
		// The API endpoint for your instance. Find it in the API endpoint section on the instance details page.
		Endpoint: tea.String("http://ha-cn-i7*****605.public.ha.aliyuncs.com"),
		// Your username. Find it in the API endpoint section on the instance details page.
		AccessUserName: tea.String("username"),
		// Your password. You can change it in the API endpoint section on the instance details page.
		AccessPassWord: tea.String("password"),
	}
	client, _clientErr := ha3engine.NewClient(config)
	// Handle client initialization errors.
	if _clientErr != nil {
		fmt.Println(_clientErr)
		return
	}
	reindex(client)
}
func reindex(client *ha3engine.Client) {
	reindexRequest := &ha3engine.ReindexRequest{}
    // The timestamp for the data version to be reindexed.
	reindexRequest.DataTimeSec = tea.Int32(1741231869)
	response, _requestErr := client.Reindex(tea.String("test_api"), reindexRequest)
	// Handle request errors.
	if _requestErr != nil {
		fmt.Println(_requestErr)
		return
	}
	// Print the response body.
	fmt.Println(response.Body)
}

Disable index table

You can call this operation in OpenAPI Explorer.

Java

import com.aliyun.ha3engine.vector.Client;
import com.aliyun.ha3engine.vector.models.Config;
import com.aliyun.ha3engine.vector.models.StopTableResponse;
import com.aliyun.tea.TeaException;
import org.junit.Before;
import org.junit.Test;
public class StopTable {
    /**
     * The ha3engine client.
     */
    private static Client client;
    @Before
    public void initClient() throws Exception {
        Config config = new Config();
        // Your username. Find it in the API Endpoint section of the Instance Details page.
        config.setAccessUserName("username");
        // Your password. You can change it in the API Endpoint section of the Instance Details page.
        config.setAccessPassWord("password");
        // The API endpoint for your instance. Find it in the API Endpoint section of the Instance Details page.
        config.setEndpoint("http://ha-cn-i7*****605.public.ha.aliyuncs.com");
        client = new Client(config);
    }
    /**
     * Stops the specified table.
     * @throws Exception
     */
    @Test
    public void stopTable() throws Exception {
        try {
            StopTableResponse response = client.stopTable("test_api");
            System.out.println(com.aliyun.teautil.Common.toJSONString(response.getBody()));
        } catch (TeaException e) {
            System.out.println(e.getCode());
            System.out.println(e.getMessage());
        }
    }
}

Python

from alibabacloud_ha3engine_vector.client import Client
from alibabacloud_ha3engine_vector.models import Config
config = Config(
    # The API endpoint for your instance. Find it in the API Endpoint section of the Instance Details page.
    endpoint="http://ha-cn-i7*****605.public.ha.aliyuncs.com",
    # Your username. Find it in the API Endpoint section of the Instance Details page.
    access_user_name="username",
    # Your password. You can change it in the API Endpoint section of the Instance Details page.
    access_pass_word="password")
client = Client(config)
def stop_table(table_name: str):
    result = client.stop_table(table_name)
    print(result.body)
if __name__ == "__main__":
    stop_table("test_api")

Go

package main
import (
	"fmt"
	"github.com/alibabacloud-go/tea/tea"
	ha3engine "github.com/aliyun/alibabacloud-ha3-go-sdk/client"
)
func main() {
	// Create a client instance.
	config := &ha3engine.Config{
		// The API endpoint for your instance. Find it in the API Endpoint section of the Instance Details page.
		Endpoint: tea.String("http://ha-cn-i7*****605.public.ha.aliyuncs.com"),
		// Your username. Find it in the API Endpoint section of the Instance Details page.
		AccessUserName: tea.String("username"),
		// Your password. You can change it in the API Endpoint section of the Instance Details page.
		AccessPassWord: tea.String("password"),
	}
	// Initialize a client to send requests.
	client, _clientErr := ha3engine.NewClient(config)
	// If client initialization fails, prints the error and returns.
	if _clientErr != nil {
		fmt.Println(_clientErr)
		return
	}
	stopTable(client)
}
func stopTable(client *ha3engine.Client) {
	response, _requestErr := client.StopTable(tea.String("test_api"))
	// If the request fails, prints the error and returns.
	if _requestErr != nil {
		fmt.Println(_requestErr)
		return
	}
	// Prints the response body.
	fmt.Println(response.Body)
}

Re-enable index table

You can call this API via the OpenAPI portal.

Java

import com.aliyun.ha3engine.vector.Client;
import com.aliyun.ha3engine.vector.models.Config;
import com.aliyun.ha3engine.vector.models.StartTableResponse;
import com.aliyun.tea.TeaException;
import org.junit.Before;
import org.junit.Test;
public class StartTable {
    /**
     * The HA3 Engine client.
     */
    private static Client client;
    @Before
    public void initClient() throws Exception {
        Config config = new Config();
        // Your username. Find it in the API endpoint section on the instance details page.
        config.setAccessUserName("username");
        // Your password. You can change it in the API endpoint section on the instance details page.
        config.setAccessPassWord("password");
        // Your API endpoint. Find it in the API endpoint section on the instance details page.
        config.setEndpoint("http://ha-cn-i7*****605.public.ha.aliyuncs.com");
        client = new Client(config);
    }
    /**
     * Starts the specified table.
     * @throws Exception
     */
    @Test
    public void startTable() throws Exception {
        try {
            StartTableResponse response = client.startTable("test_api");
            System.out.println(com.aliyun.teautil.Common.toJSONString(response.getBody()));
        } catch (TeaException e) {
            System.out.println(e.getCode());
            System.out.println(e.getMessage());
        }
    }
}

Python

from alibabacloud_ha3engine_vector.client import Client
from alibabacloud_ha3engine_vector.models import Config
config = Config(
    # Your API endpoint. Find it in the API endpoint section on the instance details page.
    endpoint="http://ha-cn-i7*****605.public.ha.aliyuncs.com",
    # Your username. Find it in the API endpoint section on the instance details page.
    access_user_name="username",
    # Your password. You can change it in the API endpoint section on the instance details page.
    access_pass_word="password")
client = Client(config)
def start_table(table_name: str):
    result = client.start_table(table_name)
    print(result.body)
if __name__ == "__main__":
    start_table("test_api")

Go

package main
import (
	"fmt"
	"github.com/alibabacloud-go/tea/tea"
	ha3engine "github.com/aliyun/alibabacloud-ha3-go-sdk/client"
)
func main() {
	// Create a client instance.
	config := &ha3engine.Config{
		// Your API endpoint. Find it in the API endpoint section on the instance details page.
		Endpoint: tea.String("http://ha-cn-i7*****605.public.ha.aliyuncs.com"),
		// Your username. Find it in the API endpoint section on the instance details page.
		AccessUserName: tea.String("username"),
		// Your password. You can change it in the API endpoint section on the instance details page.
		AccessPassWord: tea.String("password"),
	}
	client, _clientErr := ha3engine.NewClient(config)
	if _clientErr != nil {
		fmt.Println(_clientErr)
		return
	}
	startTable(client)
}
func startTable(client *ha3engine.Client) {
	response, _requestErr := client.StartTable(tea.String("test_api"))
	if _requestErr != nil {
		fmt.Println(_requestErr)
		return
	}
	fmt.Println(response.Body)
}

Delete an index table

You can call this API from the OpenAPI Portal.

Java

import com.aliyun.ha3engine.vector.Client;
import com.aliyun.ha3engine.vector.models.Config;
import com.aliyun.ha3engine.vector.models.DeleteTableResponse;
import com.aliyun.tea.TeaException;
import org.junit.Before;
import org.junit.Test;
public class DeleteTable {
    /**
     * The HA3 Engine client.
     */
    private static Client client;
    @Before
    public void initClient() throws Exception {
        Config config = new Config();
        // The username. Get this from the API Endpoints section on the Instance Details page.
        config.setAccessUserName("username");
        // The password. You can change this in the API Endpoints section on the Instance Details page.
        config.setAccessPassWord("password");
        // The API endpoint. Get this from the API Endpoints section on the Instance Details page.
        config.setEndpoint("http://ha-cn-i7*****605.public.ha.aliyuncs.com");
        client = new Client(config);
    }
    /**
     * Deletes the specified table.
     * @throws Exception
     */
    @Test
    public void deleteTable() throws Exception {
        try {
            DeleteTableResponse response = client.deleteTable("test_api");
            System.out.println(com.aliyun.teautil.Common.toJSONString(response.getBody()));
        } catch (TeaException e) {
            System.out.println(e.getCode());
            System.out.println(e.getMessage());
        }
    }
}

Python

from alibabacloud_ha3engine_vector.client import Client
from alibabacloud_ha3engine_vector.models import Config
config = Config(
    # The API endpoint. Get this from the API Endpoints section on the Instance Details page.
    endpoint="http://ha-cn-i7*****605.public.ha.aliyuncs.com",
    # The username. Get this from the API Endpoints section on the Instance Details page.
    access_user_name="username",
    # The password. You can change this in the API Endpoints section on the Instance Details page.
    access_pass_word="password")
client = Client(config)
def delete_table(table_name: str):
    result = client.delete_table(table_name)
    print(result.body)
if __name__ == "__main__":
    delete_table("test_api")

Go

package main
import (
	"fmt"
	"github.com/alibabacloud-go/tea/tea"
	ha3engine "github.com/aliyun/alibabacloud-ha3-go-sdk/client"
)
func main() {
	config := &ha3engine.Config{
		// The API endpoint. Get this from the API Endpoints section on the Instance Details page.
		Endpoint: tea.String("http://ha-cn-i7*****605.public.ha.aliyuncs.com"),
		// The username. Get this from the API Endpoints section on the Instance Details page.
		AccessUserName: tea.String("username"),
		// The password. You can change this in the API Endpoints section on the Instance Details page.
		AccessPassWord: tea.String("password"),
	}
	client, _clientErr := ha3engine.NewClient(config)
	if _clientErr != nil {
		fmt.Println(_clientErr)
		return
	}
	deleteTable(client)
}
func deleteTable(client *ha3engine.Client) {
	response, _requestErr := client.DeleteTable(tea.String("test_api"))
	if _requestErr != nil {
		fmt.Println(_requestErr)
		return
	}
	fmt.Println(response.Body)
}

List index versions

Use the OpenAPI Portal to call this API.

Java

import com.aliyun.ha3engine.vector.Client;
import com.aliyun.ha3engine.vector.models.Config;
import com.aliyun.ha3engine.vector.models.ListTableGenerationsResponse;
import com.aliyun.tea.TeaException;
import org.junit.Before;
import org.junit.Test;
public class ListTableGenerations {
    /**
     * The HA3 Engine client.
     */
    private static Client client;
    @Before
    public void initClient() throws Exception {
        Config config = new Config();
        // The username. Find this on the instance details page under API endpoint.
        config.setAccessUserName("username");
        // The password. You can change this on the instance details page under API endpoint.
        config.setAccessPassWord("password");
        // The API endpoint. Find this on the instance details page.
        config.setEndpoint("http://ha-cn-i7*****605.public.ha.aliyuncs.com");
        client = new Client(config);
    }
    /**
     * Lists the table generations.
     * @throws Exception
     */
    @Test
    public void listTableGenerations() throws Exception {
        try {
            ListTableGenerationsResponse response = client.listTableGenerations("test_api");
            System.out.println(response.getBody().getRequestId());
            System.out.println(com.aliyun.teautil.Common.toJSONString(response.getBody()));
        } catch (TeaException e) {
            System.out.println(e.getCode());
            System.out.println(e.getMessage());
        }
    }
}

Python

from alibabacloud_ha3engine_vector.client import Client
from alibabacloud_ha3engine_vector.models import Config
config = Config(
    # The API endpoint. Find this on the instance details page.
    endpoint="http://ha-cn-i7*****605.public.ha.aliyuncs.com",
    # The username. Find this on the instance details page under API endpoint.
    access_user_name="username",
    # The password. You can change this on the instance details page under API endpoint.
    access_pass_word="password")
client = Client(config)
def list_table_generations(table_name: str):
    result = client.list_table_generations(table_name)
    print(result.body)
if __name__ == "__main__":
    list_table_generations("test_api")

Go

package main
import (
	"fmt"
	"github.com/alibabacloud-go/tea/tea"
	ha3engine "github.com/aliyun/alibabacloud-ha3-go-sdk/client"
)
func main() {
	config := &ha3engine.Config{
		// The API endpoint. Find this on the instance details page.
		Endpoint: tea.String("http://ha-cn-i7*****605.public.ha.aliyuncs.com"),
		// The username. Find this on the instance details page under API endpoint.
		AccessUserName: tea.String("username"),
		// The password. You can change this on the instance details page under API endpoint.
		AccessPassWord: tea.String("password"),
	}
	// Initialize a client to send requests.
	client, _clientErr := ha3engine.NewClient(config)
	// If client initialization fails, print the error and return.
	if _clientErr != nil {
		fmt.Println(_clientErr)
		return
	}
	listTableGenerations(client)
}
func listTableGenerations(client *ha3engine.Client) {
	response, _requestErr := client.ListTableGenerations(tea.String("test"))
	// If the request fails, print the error and return.
	if _requestErr != nil {
		fmt.Println(_requestErr)
		return
	}
	// Print the body of the successful response.
	fmt.Println(response.Body)
}

Index version status by generationId

You can call this operation from the .

Java

import com.aliyun.ha3engine.vector.Client;
import com.aliyun.ha3engine.vector.models.Config;
import com.aliyun.ha3engine.vector.models.GetTableGenerationResponse;
import com.aliyun.tea.TeaException;
import org.junit.Before;
import org.junit.Test;
public class GetTableGeneration {
    /**
     * The ha3engine client.
     */
    private static Client client;
    @Before
    public void initClient() throws Exception {
        Config config = new Config();
        // Your username. Find it in the api endpoint section on the instance details page.
        config.setAccessUserName("username");
        // Your password. Find it in the api endpoint section on the instance details page.
        config.setAccessPassWord("password");
        // The api endpoint for your instance. Find it in the api endpoint section on the instance details page.
        config.setEndpoint("http://ha-cn-i7*****605.public.ha.aliyuncs.com");
        client = new Client(config);
    }
    /**
     * Gets the status of a table generation by its generationId.
     * @throws Exception
     */
    @Test
    public void getTableGeneration() throws Exception {
        try {
            GetTableGenerationResponse response = client.getTableGeneration("table_name", "1742520880");
            System.out.println(response.getBody().getRequestId());
            System.out.println(com.aliyun.teautil.Common.toJSONString(response.getBody()));
        } catch (TeaException e) {
            System.out.println(e.getCode());
            System.out.println(e.getMessage());
        }
    }
}

Python

from alibabacloud_ha3engine_vector.client import Client
from alibabacloud_ha3engine_vector.models import Config
config = Config(
    # The api endpoint for your instance. Find it in the api endpoint section on the instance details page.
    endpoint="http://ha-cn-i7*****605.public.ha.aliyuncs.com",
    # Your username. Find it in the api endpoint section on the instance details page.
    access_user_name="username",
    # Your password. Find it in the api endpoint section on the instance details page.
    access_pass_word="password")
client = Client(config)
def get_table_generation(table_name: str, generation_id: str):
    result = client.get_table_generation(table_name, generation_id)
    print(result.body)
if __name__ == "__main__":
    get_table_generation("test_api", "1742453479")

Go

package main
import (
	"fmt"
	"github.com/alibabacloud-go/tea/tea"
	ha3engine "github.com/aliyun/alibabacloud-ha3-go-sdk/client"
)
func main() {
	// Create a client instance.
	config := &ha3engine.Config{
		// The api endpoint for your instance. Find it in the api endpoint section on the instance details page.
		Endpoint: tea.String("http://ha-cn-i7*****605.public.ha.aliyuncs.com"),
		// Your username. Find it in the api endpoint section on the instance details page.
		AccessUserName: tea.String("username"),
		// Your password. Find it in the api endpoint section on the instance details page.
		AccessPassWord: tea.String("password"),
	}
	// Initialize a client to send requests.
	client, _clientErr := ha3engine.NewClient(config)
	// If an error occurs during client initialization, print the error message and return.
	if _clientErr != nil {
		fmt.Println(_clientErr)
		return
	}
	getTableGeneration(client)
}
func getTableGeneration(client *ha3engine.Client) {
	response, _requestErr := client.GetTableGeneration(tea.String("test"), tea.String("1742349911"))
	// If an error occurs while sending the request, print the error message and return.
	if _requestErr != nil {
		fmt.Println(_requestErr)
		return
	}
	// Print the body of the successful response.
	fmt.Println(response.Body)
}

Change history

You can call this API in the OpenAPI portal.

Java

import com.aliyun.ha3engine.vector.Client;
import com.aliyun.ha3engine.vector.models.Config;
import com.aliyun.ha3engine.vector.models.ListTasksRequest;
import com.aliyun.ha3engine.vector.models.ListTasksResponse;
import com.aliyun.tea.TeaException;
import org.junit.Before;
import org.junit.Test;
public class ListTasks {
    /**
     * The Havenask engine client.
     */
    private static Client client;
    @Before
    public void initClient() throws Exception {
        Config config = new Config();
        // Your username. Find it on the Instance Details page in the API Endpoint section.
        config.setAccessUserName("username");
        // Your password. You can change it on the Instance Details page in the API Endpoint section.
        config.setAccessPassWord("password");
        // The API endpoint for your instance. Find it on the Instance Details page in the API Endpoint section.
        config.setEndpoint("http://ha-cn-i7*****605.public.ha.aliyuncs.com");
        client = new Client(config);
    }
    /**
     * Lists tasks.
     * @throws Exception
     */
    @Test
    public void listTasks() throws Exception {
        try {
            // Request parameters.
            ListTasksRequest request = new ListTasksRequest();
            // Start timestamp.
            request.setStart(1741331885L);
            // End timestamp.
            request.setEnd(1742521261750L);
            ListTasksResponse response = client.listTasks(request);
            System.out.println(com.aliyun.teautil.Common.toJSONString(response.getBody()));
        } catch (TeaException e) {
            System.out.println(e.getCode());
            System.out.println(e.getMessage());
        }
    }
}

Python

from alibabacloud_ha3engine_vector.client import Client
from alibabacloud_ha3engine_vector.models import Config, ListTasksRequest
config = Config(
    # The API endpoint for your instance. Find it on the Instance Details page in the API Endpoint section.
    endpoint="http://ha-cn-i7*****605.public.ha.aliyuncs.com",
    # Your username. Find it on the Instance Details page in the API Endpoint section.
    access_user_name="username",
    # Your password. You can change it on the Instance Details page in the API Endpoint section.
    access_pass_word="password")
client = Client(config)
def list_tasks():
    # Request parameters.
    request = ListTasksRequest()
    # Start timestamp.
    request.start = 1741331885
    # End timestamp.
    request.end = 1742521261750
    result = client.list_tasks(request)
    print(result.body)
if __name__ == "__main__":
    list_tasks()

Go

package main
import (
	"fmt"
	"github.com/alibabacloud-go/tea/tea"
	ha3engine "github.com/aliyun/alibabacloud-ha3-go-sdk/client"
)
func main() {
	// Define the client configuration.
	config := &ha3engine.Config{
		// The API endpoint for your instance. Find it on the Instance Details page in the API Endpoint section.
		Endpoint: tea.String("http://ha-cn-i7*****605.public.ha.aliyuncs.com"),
		// Your username. Find it on the Instance Details page in the API Endpoint section.
		AccessUserName: tea.String("username"),
		// Your password. You can change it on the Instance Details page in the API Endpoint section.
		AccessPassWord: tea.String("password"),
	}
	// Create a client from the configuration.
	client, _clientErr := ha3engine.NewClient(config)
	// If an error occurs during client creation, print it and return.
	if _clientErr != nil {
		fmt.Println(_clientErr)
		return
	}
	listTasks(client)
}
func listTasks(client *ha3engine.Client) {
	request := &ha3engine.ListTasksRequest{}
    // Start timestamp.
	request.Start = tea.Int64(1741331885)
    // End timestamp.
	request.End = tea.Int64(1742521261750)
	response, _requestErr := client.ListTasks(request)
	// If an error occurs during the request, print it and return.
	if _requestErr != nil {
		fmt.Println(_requestErr)
		return
	}
	// Print the response body.
	fmt.Println(response.Body)
}