MCPcopy Create free account
hub / github.com/alibaba/proxima / main

Function main

sdk/cpp/examples/client_example.cc:27–197  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

25using namespace proxima::be;
26
27int main() {
28 // Create a client instance
29 ProximaSearchClientPtr client = ProximaSearchClient::Create();
30
31 // Try to connect server
32 {
33 ChannelOptions options("127.0.0.1:16000");
34 Status status = client->connect(options);
35 if (status.code != 0) {
36 std::cerr << "Connect server failed. code[" << status.code << "] reason["
37 << status.reason << "]" << std::endl;
38 return status.code;
39 }
40 std::cout << "===>Connect server success." << std::endl;
41 }
42
43 // Create collection
44 {
45 // Describe a collection config which
46 // set collection name --> "test_collection"
47 // set one index column --> "test_column"
48 // set two forward columsn --> "fwd_column1" and "fwd_column2"
49 CollectionConfig config;
50 config.collection_name = "test_collection";
51 config.forward_columns = {"fwd_column1", "fwd_column2"};
52 config.index_columns = {
53 IndexColumnParam("test_column", DataType::VECTOR_FP32, 8)};
54
55 Status status = client->create_collection(config);
56 if (status.code != 0) {
57 std::cerr << "Create collection failed. code[" << status.code
58 << "] reason[" << status.reason << "]" << std::endl;
59 return status.code;
60 }
61 std::cout << "===>Create collection success." << std::endl;
62 }
63
64 // Get collection information
65 {
66 CollectionInfo collection_info;
67 Status status =
68 client->describe_collection("test_collection", &collection_info);
69 if (status.code != 0) {
70 std::cerr << "Describe collection failed. code[" << status.code
71 << "] reason[" << status.reason << "]" << std::endl;
72 return status.code;
73 }
74
75 std::cout << "===>Describe collection success." << std::endl;
76 std::cout << "collection_name: " << collection_info.collection_name
77 << std::endl;
78 std::cout << "collection_status: " << (int)collection_info.collection_status
79 << std::endl;
80 std::cout << "collection_uuid: " << collection_info.collection_uuid
81 << std::endl;
82 for (size_t i = 0; i < collection_info.forward_columns.size(); i++) {
83 std::cout << "forward_column: " << collection_info.forward_columns[i]
84 << std::endl;

Callers

nothing calls this directly

Calls 15

add_forward_columnsMethod · 0.80
add_index_columnMethod · 0.80
add_rowMethod · 0.80
set_operation_typeMethod · 0.80
add_index_valueMethod · 0.80
add_forward_valueMethod · 0.80
add_knn_query_paramMethod · 0.80
set_topkMethod · 0.80
set_featuresMethod · 0.80
result_countMethod · 0.80
resultMethod · 0.80
document_countMethod · 0.80

Tested by

no test coverage detected