From 19ab3a8c760fa5e7e6cfab1b2ff97c187589efae Mon Sep 17 00:00:00 2001 From: shikeying <pxzsky@163.com> Date: 星期三, 08 五月 2024 11:57:22 +0800 Subject: [PATCH] 去掉加密文件验证 --- walker-support-milvus/src/main/java/com/walker/support/milvus/engine/DefaultOperateService.java | 42 +++++++++++++++++++++++++++++++++++------- 1 files changed, 35 insertions(+), 7 deletions(-) diff --git a/walker-support-milvus/src/main/java/com/walker/support/milvus/engine/DefaultOperateService.java b/walker-support-milvus/src/main/java/com/walker/support/milvus/engine/DefaultOperateService.java index d32c455..6228326 100644 --- a/walker-support-milvus/src/main/java/com/walker/support/milvus/engine/DefaultOperateService.java +++ b/walker-support-milvus/src/main/java/com/walker/support/milvus/engine/DefaultOperateService.java @@ -147,14 +147,15 @@ return false; } if(statusR.getStatus().intValue() == R.Status.Success.getCode()){ - logger.error("insert 杩斿洖鍊硷細" + statusR.getStatus().intValue()); + logger.debug("insert 杩斿洖鍊硷細" + statusR.getStatus().intValue()); return true; } return false; } @Override - public boolean createIndex(String tableName, String fieldName, String indexType, String indexParam){ + public boolean createIndex(String tableName, String fieldName, String indexType, String indexParam + , com.walker.support.milvus.MetricType myMetricType){ this.checkConnection(); IndexType INDEX_TYPE = null; if(indexType.equals("IVF_FLAT")){ @@ -165,22 +166,43 @@ INDEX_TYPE = IndexType.IVF_PQ; } else if(indexType.equals("HNSW")){ INDEX_TYPE = IndexType.HNSW; - } else if(indexType.equals("ANNOY")){ - INDEX_TYPE = IndexType.ANNOY; - } else if(indexType.equals("FLAT")){ + } + else if(indexType.equals("ANNOY")){ +// INDEX_TYPE = IndexType.ANNOY; + throw new UnsupportedOperationException("鏂扮増鏈凡涓嶆敮鎸侊細ANNOY"); + } + else if(indexType.equals("FLAT")){ INDEX_TYPE = IndexType.FLAT; + } else if(indexType.equals("GPU_IVF_FLAT")){ + INDEX_TYPE = IndexType.GPU_IVF_FLAT; + } else if(indexType.equals("GPU_IVF_PQ")){ + INDEX_TYPE = IndexType.GPU_IVF_PQ; + } else if(indexType.equals("SCANN")){ + INDEX_TYPE = IndexType.SCANN; } else { throw new IllegalArgumentException("鏆備笉鏀寔鍏朵粬绱㈠紩绫诲瀷锛�" + indexType); } + /** + * 鈥�**娆ф皬璺濈 (L2)**鈥�: 涓昏杩愮敤浜庤绠楁満瑙嗚棰嗗煙銆� + * 鈥�**鍐呯Н (IP)**鈥�: 涓昏杩愮敤浜庤嚜鐒惰瑷�澶勭悊锛圢LP锛夐鍩熴�� + * @date 2024-03-26 + */ CreateIndexParam.Builder builder = CreateIndexParam.newBuilder(); builder.withCollectionName(tableName) .withFieldName(fieldName) .withIndexName(fieldName + "_index") .withIndexType(INDEX_TYPE) - .withMetricType(MetricType.L2) +// .withMetricType(MetricType.L2) .withExtraParam(indexParam) .withSyncMode(false); + if(myMetricType == com.walker.support.milvus.MetricType.NLP){ + builder.withMetricType(MetricType.IP); + } else if(myMetricType == com.walker.support.milvus.MetricType.IMAGE){ + builder.withMetricType(MetricType.L2); + } else { + throw new UnsupportedOperationException("鏆傛椂涓嶆敮鎸佽窛绂荤被鍨嬶細" + myMetricType); + } R<RpcStatus> statusR = this.client.createIndex(builder.build()); return checkStatusR(statusR); @@ -232,6 +254,12 @@ MetricType metricType = null; if(query.getMetricType() == null || query.getMetricType().equals("")){ metricType = MetricType.L2; + } else if(query.getMetricType().equals(com.walker.support.milvus.MetricType.INDEX_IMAGE)){ + metricType = MetricType.L2; + } else if(query.getMetricType().equals(com.walker.support.milvus.MetricType.INDEX_NLP)){ + metricType = MetricType.IP; + } else { + throw new UnsupportedOperationException("鏆傛湭鏀寔鐨勮窛绂荤被鍨嬶細" + query.getMetricType()); } SearchParam searchParam = SearchParam.newBuilder() @@ -265,7 +293,7 @@ if(outField.equals("id")){ outData.setKeyList((List<Long>)wrapperSearch.getFieldData("id", 0)); } else { - outData.setBusinessIdList((List<Long>)wrapperSearch.getFieldData(outField, 0)); + outData.setBusinessIdList((List<String>)wrapperSearch.getFieldData(outField, 0)); } } // System.out.println(wrapperSearch.getFieldData("book_id", 0)); -- Gitblit v1.9.1