فهرست منبع

Merge pull request #42 from youny626/0.2.0

fix search result validation
Jin Hai 6 سال پیش
والد
کامیت
4cc97b5c3c
3فایلهای تغییر یافته به همراه3 افزوده شده و 2 حذف شده
  1. 1 0
      CHANGELOG.md
  2. 1 1
      examples/src/main/java/MilvusClientExample.java
  3. 1 1
      src/test/java/io/milvus/client/MilvusGrpcClientTest.java

+ 1 - 0
CHANGELOG.md

@@ -6,6 +6,7 @@
 
 
 ### Bug
 ### Bug
 ---
 ---
+- \#42: fix search result validation
     
     
 ### Improvement
 ### Improvement
 ---
 ---

+ 1 - 1
examples/src/main/java/MilvusClientExample.java

@@ -147,7 +147,7 @@ public class MilvusClientExample {
         // very close to 1 (some precision is lost during the process)
         // very close to 1 (some precision is lost during the process)
         SearchResponse.QueryResult firstQueryResult = queryResultsList.get(i).get(0);
         SearchResponse.QueryResult firstQueryResult = queryResultsList.get(i).get(0);
         if (firstQueryResult.getVectorId() != vectorIds.get(i)
         if (firstQueryResult.getVectorId() != vectorIds.get(i)
-            || Math.abs(1 - firstQueryResult.getDistance()) > (1 - epsilon)) {
+            || Math.abs(1 - firstQueryResult.getDistance()) > epsilon) {
           throw new AssertionError("Wrong results!");
           throw new AssertionError("Wrong results!");
         }
         }
       }
       }

+ 1 - 1
src/test/java/io/milvus/client/MilvusGrpcClientTest.java

@@ -190,7 +190,7 @@ class MilvusClientTest {
     for (int i = 0; i < searchSize; i++) {
     for (int i = 0; i < searchSize; i++) {
       SearchResponse.QueryResult firstQueryResult = queryResultsList.get(i).get(0);
       SearchResponse.QueryResult firstQueryResult = queryResultsList.get(i).get(0);
       assertEquals(vectorIds.get(i), firstQueryResult.getVectorId());
       assertEquals(vectorIds.get(i), firstQueryResult.getVectorId());
-      assertTrue(Math.abs(1 - firstQueryResult.getDistance()) < (1 - epsilon));
+      assertTrue(Math.abs(1 - firstQueryResult.getDistance()) < epsilon);
     }
     }
   }
   }