소스 검색

ListIndexes returns empty if no index exists (#1012)

Signed-off-by: yhmo <yihua.mo@zilliz.com>
groot 9 달 전
부모
커밋
796eb9c7f6
1개의 변경된 파일5개의 추가작업 그리고 0개의 파일을 삭제
  1. 5 0
      src/main/java/io/milvus/v2/service/index/IndexService.java

+ 5 - 0
src/main/java/io/milvus/v2/service/index/IndexService.java

@@ -145,6 +145,11 @@ public class IndexService extends BaseService {
                     .build();
         }
         DescribeIndexResponse response = blockingStub.describeIndex(describeIndexRequest);
+        // if the collection has no index, return empty list, instead of throwing an exception
+        if (response.getStatus().getErrorCode() == io.milvus.grpc.ErrorCode.IndexNotExist ||
+                response.getStatus().getCode() == 700) {
+            return new ArrayList<>();
+        }
         rpcUtils.handleResponse(title, response.getStatus());
         List<String> indexNames = new ArrayList<>();
         response.getIndexDescriptionsList().forEach(index -> {