Browse Source

ListIndexes returns empty if no index exists (#1012)

Signed-off-by: yhmo <yihua.mo@zilliz.com>
groot 9 months ago
parent
commit
796eb9c7f6
1 changed files with 5 additions and 0 deletions
  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();
                     .build();
         }
         }
         DescribeIndexResponse response = blockingStub.describeIndex(describeIndexRequest);
         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());
         rpcUtils.handleResponse(title, response.getStatus());
         List<String> indexNames = new ArrayList<>();
         List<String> indexNames = new ArrayList<>();
         response.getIndexDescriptionsList().forEach(index -> {
         response.getIndexDescriptionsList().forEach(index -> {