提交 0acc0b98 编写于 作者: Z zw

add java case

Signed-off-by: Nzw <zw@milvus.io>
上级 f4744c7d
......@@ -14,6 +14,7 @@ public class TestSearchByIds {
int n_list = 1024;
int default_n_list = 16384;
int nb = 10000;
int small_nb = 10;
int n_probe = 20;
int top_k = 10;
int nq = 5;
......@@ -22,6 +23,7 @@ public class TestSearchByIds {
IndexType defaultIndexType = IndexType.FLAT;
List<Long> default_ids = Utils.toListIds(1111);
List<List<Float>> vectors = Utils.genVectors(nb, dimension, true);
List<List<Float>> small_vectors = Utils.genVectors(small_nb, dimension, true);
List<ByteBuffer> vectorsBinary = Utils.genBinaryVectors(nb, dimension);
String indexParam = Utils.setIndexParam(n_list);
public String searchParamStr = Utils.setSearchParam(n_probe);
......@@ -62,8 +64,22 @@ public class TestSearchByIds {
List<List<SearchResponse.QueryResult>> res_search = client.searchByIds(searchParam).getQueryResultsList();
assert (client.searchByIds(searchParam).getResponse().ok());
Assert.assertEquals(res_search.get(0).size(), 0);
// Assert.assertEquals(res_search.size(), default_ids.size());
// Assert.assertEquals(res_search.get(0).get(0).getVectorId(), -1);
}
@Test(dataProvider = "Collection", dataProviderClass = MainClass.class)
public void test_search_count_lt_top_k(MilvusClient client, String collectionName) {
int top_k = 100;
InsertParam insertParam = new InsertParam.Builder(collectionName).withFloatVectors(small_vectors).build();
InsertResponse res_insert = client.insert(insertParam);
client.flush(collectionName);
SearchByIdsParam searchParam = new SearchByIdsParam.Builder(collectionName)
.withParamsInJson(searchParamStr)
.withTopK(top_k)
.withIDs(Utils.toListIds(res_insert.getVectorIds().get(0)))
.build();
List<List<SearchResponse.QueryResult>> res_search = client.searchByIds(searchParam).getQueryResultsList();
// reason: "Failed to query by id in collection L2_FmVKbqSZaN, result doesn\'t match id count"
assert (!client.searchByIds(searchParam).getResponse().ok());
}
@Test(dataProvider = "Collection", dataProviderClass = MainClass.class)
......
......@@ -15,6 +15,7 @@ public class TestSearchVectors {
int n_list = 1024;
int default_n_list = 16384;
int nb = 10000;
int small_nb = 10;
int n_probe = 20;
int top_k = 10;
int nq = 5;
......@@ -22,6 +23,7 @@ public class TestSearchVectors {
IndexType indexType = IndexType.IVF_SQ8;
IndexType defaultIndexType = IndexType.FLAT;
List<List<Float>> vectors = Utils.genVectors(nb, dimension, true);
List<List<Float>> small_vectors = Utils.genVectors(small_nb, dimension, true);
List<ByteBuffer> vectorsBinary = Utils.genBinaryVectors(nb, dimension);
List<List<Float>> queryVectors = vectors.subList(0, nq);
List<ByteBuffer> queryVectorsBinary = vectorsBinary.subList(0, nq);
......@@ -190,6 +192,21 @@ public class TestSearchVectors {
assert (!res_search.getResponse().ok());
}
@Test(dataProvider = "Collection", dataProviderClass = MainClass.class)
public void test_search_count_lt_top_k(MilvusClient client, String collectionName) {
int top_k_new = 100;
InsertParam insertParam = new InsertParam.Builder(collectionName).withFloatVectors(small_vectors).build();
client.insert(insertParam);
client.flush(collectionName);
SearchParam searchParam = new SearchParam.Builder(collectionName)
.withFloatVectors(queryVectors)
.withParamsInJson(searchParamStr)
.withTopK(top_k_new).build();
List<List<SearchResponse.QueryResult>> res_search = client.search(searchParam).getQueryResultsList();
Assert.assertEquals(res_search.size(), nq);
Assert.assertEquals(res_search.get(0).size(), small_vectors.size());
}
@Test(dataProvider = "Collection", dataProviderClass = MainClass.class)
public void test_search_invalid_top_k(MilvusClient client, String collectionName) {
int top_k_new = 0;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册