|
@@ -1,107 +1,10 @@
|
|
|
-import {
|
|
|
- IndexCreateParam,
|
|
|
- IndexManageParam,
|
|
|
- IndexView,
|
|
|
-} from '../pages/schema/Types';
|
|
|
-import { ManageRequestMethods } from '../types/Common';
|
|
|
-import { IndexState } from '../types/Milvus';
|
|
|
-import { findKeyValue } from '../utils/Common';
|
|
|
-import { getKeyValueListFromJsonString } from '../utils/Format';
|
|
|
-import BaseModel from './BaseModel';
|
|
|
-
|
|
|
-export class IndexHttp extends BaseModel implements IndexView {
|
|
|
- params!: { key: string; value: string }[];
|
|
|
- field_name!: string;
|
|
|
- index_name!: string;
|
|
|
-
|
|
|
- constructor(props: {}) {
|
|
|
- super(props);
|
|
|
- Object.assign(this, props);
|
|
|
- }
|
|
|
-
|
|
|
- static BASE_URL = `/schema/index`;
|
|
|
-
|
|
|
- static async getIndexStatus(
|
|
|
- collectionName: string,
|
|
|
- fieldName: string,
|
|
|
- indexName: string
|
|
|
- ): Promise<{ state: IndexState }> {
|
|
|
- const path = `${this.BASE_URL}/state`;
|
|
|
- return super.search({
|
|
|
- path,
|
|
|
- params: {
|
|
|
- collection_name: collectionName,
|
|
|
- field_name: fieldName,
|
|
|
- index_name: indexName,
|
|
|
- },
|
|
|
- });
|
|
|
- }
|
|
|
-
|
|
|
- static async getIndexInfo(collectionName: string): Promise<IndexHttp[]> {
|
|
|
- const path = this.BASE_URL;
|
|
|
-
|
|
|
- const res = await super.findAll({
|
|
|
- path,
|
|
|
- params: { collection_name: collectionName },
|
|
|
- });
|
|
|
- return res.index_descriptions.map((index: any) => new this(index));
|
|
|
- }
|
|
|
-
|
|
|
- static async createIndex(param: IndexCreateParam) {
|
|
|
- const path = this.BASE_URL;
|
|
|
- const type: ManageRequestMethods = ManageRequestMethods.CREATE;
|
|
|
-
|
|
|
- return super.create({
|
|
|
- path,
|
|
|
- data: { ...param, type },
|
|
|
- });
|
|
|
- }
|
|
|
-
|
|
|
- static async deleteIndex(param: IndexManageParam) {
|
|
|
- const path = this.BASE_URL;
|
|
|
- const type: ManageRequestMethods = ManageRequestMethods.DELETE;
|
|
|
-
|
|
|
- return super.batchDelete({ path, data: { ...param, type } });
|
|
|
- }
|
|
|
-
|
|
|
- static async getIndexBuildProgress(
|
|
|
- collectionName: string,
|
|
|
- fieldName: string,
|
|
|
- indexName: string
|
|
|
- ) {
|
|
|
- const path = `${this.BASE_URL}/progress`;
|
|
|
- return super.search({
|
|
|
- path,
|
|
|
- params: {
|
|
|
- collection_name: collectionName,
|
|
|
- field_name: fieldName,
|
|
|
- index_name: indexName,
|
|
|
- },
|
|
|
- });
|
|
|
- }
|
|
|
-
|
|
|
- get _indexType() {
|
|
|
- return this.params.find(p => p.key === 'index_type')?.value || '';
|
|
|
- }
|
|
|
- get _indexName() {
|
|
|
- return this.index_name;
|
|
|
- }
|
|
|
-
|
|
|
- get _indexParameterPairs() {
|
|
|
- const metricType = this.params.filter(v => v.key === 'metric_type');
|
|
|
- // parms is json string, so we need parse it to key value array
|
|
|
- const params = findKeyValue(this.params, 'params');
|
|
|
- if (params) {
|
|
|
- return [...metricType, ...getKeyValueListFromJsonString(params)];
|
|
|
- }
|
|
|
- return metricType;
|
|
|
- }
|
|
|
-
|
|
|
- get _fieldName() {
|
|
|
- return this.field_name;
|
|
|
- }
|
|
|
-
|
|
|
- get _metricType() {
|
|
|
- return this.params.find(p => p.key === 'metric_type')?.value || '';
|
|
|
- }
|
|
|
-}
|
|
|
+export * from './Axios';
|
|
|
+export * from './BaseModel';
|
|
|
+export * from './Collection';
|
|
|
+export * from './Database';
|
|
|
+export * from './Milvus';
|
|
|
+export * from './MilvusIndex';
|
|
|
+export * from './Field';
|
|
|
+export * from './Partition';
|
|
|
+export * from './Prometheus';
|
|
|
+export * from './User';
|