milvus.thrift 7.1 KB
Newer Older
G
groot 已提交
1 2 3 4 5
/*******************************************************************************
 * Copyright 上海赜睿信息科技有限公司(Zilliz) - All Rights Reserved
 * Unauthorized copying of this file, via any medium is strictly prohibited.
 * Proprietary and confidential.
 ******************************************************************************/
G
groot 已提交
6 7 8 9 10 11 12 13 14
namespace cpp milvus.thrift
namespace py milvus.thrift
namespace d milvus.thrift
namespace dart milvus.thrift
namespace java milvus.thrift
namespace perl milvus.thrift
namespace php milvus.thrift
namespace haxe milvus.thrift
namespace netcore milvus.thrift
G
groot 已提交
15 16

enum ErrorCode {
G
groot 已提交
17
    SUCCESS = 0,
G
groot 已提交
18
    UNEXPECTED_ERROR,
G
groot 已提交
19 20
    CONNECT_FAILED,
    PERMISSION_DENIED,
G
groot 已提交
21 22 23 24
    TABLE_NOT_EXISTS,
    ILLEGAL_ARGUMENT,
    ILLEGAL_RANGE,
    ILLEGAL_DIMENSION,
G
groot 已提交
25 26 27 28 29 30 31 32 33 34 35 36 37
    ILLEGAL_INDEX_TYPE,
    ILLEGAL_TABLE_NAME,
    ILLEGAL_TOPK,
    ILLEGAL_ROWRECORD,
    ILLEGAL_VECTOR_ID,
    ILLEGAL_SEARCH_RESULT,
    FILE_NOT_FOUND,
    META_FAILED,
    CACHE_FAILED,
    CANNOT_CREATE_FOLDER,
    CANNOT_CREATE_FILE,
    CANNOT_DELETE_FOLDER,
    CANNOT_DELETE_FILE,
P
peng.xu 已提交
38
    BUILD_INDEX_ERROR,
G
groot 已提交
39 40
}

G
groot 已提交
41
exception Exception {
G
groot 已提交
42 43
    1: ErrorCode code;
    2: string reason;
G
groot 已提交
44 45 46
}


G
groot 已提交
47 48 49 50
/**
 * @brief Table Schema
 */
struct TableSchema {
G
groot 已提交
51 52 53 54
    1: required string table_name;                   ///< Table name
    2: i32 index_type = 0;                           ///< Index type, optional: 0-invalid, 1-idmap, 2-ivflat
    3: i64 dimension = 0;                            ///< Vector dimension
    4: bool store_raw_vector = false;                ///< Store raw data
G
groot 已提交
55 56
}

G
groot 已提交
57 58 59 60
/**
 * @brief Range Schema
 */
struct Range {
G
groot 已提交
61 62
    1: string start_value;                           ///< Range start
    2: string end_value;                             ///< Range stop
G
groot 已提交
63 64
}

G
groot 已提交
65 66 67 68
/**
 * @brief Record inserted
 */
struct RowRecord {
G
groot 已提交
69
    1: required binary vector_data;                  ///< Vector data, double array
G
groot 已提交
70 71
}

G
groot 已提交
72
/**
G
groot 已提交
73
 * @brief Query result
G
groot 已提交
74
 */
G
groot 已提交
75
struct QueryResult {
G
groot 已提交
76
    1: i64 id;                                       ///< Output result
J
jinhai 已提交
77
    2: double distance;                              ///< Vector similarity distance
G
groot 已提交
78 79
}

G
groot 已提交
80
/**
G
groot 已提交
81
 * @brief TopK query result
G
groot 已提交
82
 */
G
groot 已提交
83
struct TopKQueryResult {
G
groot 已提交
84
    1: list<QueryResult> query_result_arrays;        ///< TopK query result
G
groot 已提交
85 86
}

87 88 89 90 91 92 93 94
/**
 * @brief TopK query binary result
 */
struct TopKQueryBinResult {
    1: required binary id_array;                     ///< id array, interger array
    2: required binary distance_array;               ///< distance array, double array
}

G
groot 已提交
95
service MilvusService {
G
groot 已提交
96
    /**
G
groot 已提交
97 98 99 100 101 102 103 104 105
     * @brief Create table method
     *
     * This method is used to create table
     *
     * @param param, use to provide table information to be created.
     *
     */
    void CreateTable(2: TableSchema param) throws(1: Exception e);

G
groot 已提交
106 107 108 109 110 111 112 113 114 115
    /**
     * @brief Test table existence method
     *
     * This method is used to test table existence.
     *
     * @param table_name, table name is going to be tested.
     *
     */
    bool HasTable(2: string table_name) throws(1: Exception e);

G
groot 已提交
116 117 118 119 120 121 122 123

    /**
     * @brief Delete table method
     *
     * This method is used to delete table.
     *
     * @param table_name, table name is going to be deleted.
     *
G
groot 已提交
124
     */
G
groot 已提交
125
    void DeleteTable(2: string table_name) throws(1: Exception e);
G
groot 已提交
126

P
peng.xu 已提交
127 128 129 130 131 132 133 134 135 136
    /**
     * @brief Build index by table method
     *
     * This method is used to build index by table in sync mode.
     *
     * @param table_name, table is going to be built index.
     *
     */
    void BuildIndex(2: string table_name) throws(1: Exception e);

G
groot 已提交
137

G
groot 已提交
138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158
    /**
     * @brief Add vector array to table
     *
     * This method is used to add vector array to table.
     *
     * @param table_name, table_name is inserted.
     * @param record_array, vector array is inserted.
     *
     * @return vector id array
     */
    list<i64> AddVector(2: string table_name,
                        3: list<RowRecord> record_array) throws(1: Exception e);


    /**
     * @brief Query vector
     *
     * This method is used to query vector in table.
     *
     * @param table_name, table_name is queried.
     * @param query_record_array, all vector are going to be queried.
G
groot 已提交
159
     * @param query_range_array, optional ranges for conditional search. If not specified, search whole table
G
groot 已提交
160 161 162 163 164
     * @param topk, how many similarity vectors will be searched.
     *
     * @return query result array.
     */
    list<TopKQueryResult> SearchVector(2: string table_name,
G
groot 已提交
165 166 167 168
                                       3: list<RowRecord> query_record_array,
                                       4: list<Range> query_range_array,
                                       5: i64 topk) throws(1: Exception e);

169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185
    /**
     * @brief Query vector
     *
     * This method is used to query vector in table.
     *
     * @param table_name, table_name is queried.
     * @param query_record_array, all vector are going to be queried.
     * @param query_range_array, optional ranges for conditional search. If not specified, search whole table
     * @param topk, how many similarity vectors will be searched.
     *
     * @return query binary result array.
     */
    list<TopKQueryBinResult> SearchVector2(2: string table_name,
                                           3: list<RowRecord> query_record_array,
                                           4: list<Range> query_range_array,
                                           5: i64 topk) throws(1: Exception e);

186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202
    /**
     * @brief Internal use query interface
     *
     * This method is used to query vector in specified files.
     *
     * @param file_id_array, specified files id array, queried.
     * @param query_record_array, all vector are going to be queried.
     * @param query_range_array, optional ranges for conditional search. If not specified, search whole table
     * @param topk, how many similarity vectors will be searched.
     *
     * @return query result array.
     */
    list<TopKQueryResult> SearchVectorInFiles(2: string table_name,
                                              3: list<string> file_id_array,
                                              4: list<RowRecord> query_record_array,
                                              5: list<Range> query_range_array,
                                              6: i64 topk) throws(1: Exception e);
G
groot 已提交
203 204

    /**
G
groot 已提交
205
     * @brief Get table schema
G
groot 已提交
206
     *
G
groot 已提交
207
     * This method is used to get table schema.
G
groot 已提交
208
     *
G
groot 已提交
209
     * @param table_name, target table name.
G
groot 已提交
210 211 212 213 214
     *
     * @return table schema
     */
    TableSchema DescribeTable(2: string table_name) throws(1: Exception e);

G
groot 已提交
215 216 217 218 219 220 221 222 223 224 225 226

    /**
     * @brief Get table row count
     *
     * This method is used to get table row count.
     *
     * @param table_name, target table name.
     *
     * @return table row count
     */
    i64 GetTableRowCount(2: string table_name) throws(1: Exception e);

G
groot 已提交
227 228 229 230 231 232 233 234 235 236
    /**
     * @brief List all tables in database
     *
     * This method is used to list all tables.
     *
     *
     * @return table names.
     */
    list<string> ShowTables() throws(1: Exception e);

G
groot 已提交
237

G
groot 已提交
238 239 240 241 242 243
    /**
     * @brief Give the server status
     *
     * This method is used to give the server status.
     *
     * @return Server status.
G
groot 已提交
244
     */
G
groot 已提交
245
    string Ping(2: string cmd) throws(1: Exception e);
P
peng.xu 已提交
246
}