Browse Source

Merge pull request #42 from youny626/0.2.0

fix search result validation
Jin Hai 5 years ago
parent
commit
4cc97b5c3c

+ 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);
     }
     }
   }
   }