ANN 查询数据 id返回值错误
Opened this issue · 3 comments
Stefankeep commented
collection 设置 主键为 VarChar(32)
在查询时返回值为
"rowRecords" : [ {
"fieldValues" : {
"distance" : 0.62605506,
"id" : 0
}
}, {
"fieldValues" : {
"distance" : 0.9031652,
"id" : 0
}
}, {
"fieldValues" : {
"distance" : 0.9675503,
"id" : 0
}]
}
查询参数为
SearchParam{collectionName='chat_kb', partitionNames='[]', metricType=L2, target vectors count=1, vectorFieldName='vector', topK=10, nq=1, expr='', params='{"offset":0}', consistencyLevel='null', ignoreGrowing='false'}
无法返回正确的 uuid 作为业务关联使用
xiaofan-luan commented
what is your schema of your collection?
is id your primary key field?
is it autoIncrement or user specified
yhmo commented
Use the 'SearchResultsWrapper
' class to print out all the search results:
SearchParam searchParam = SearchParam.newBuilder()
.withCollectionName(randomCollectionName)
.withMetricType(MetricType.IP)
.withTopK(topK)
.withVectors(targetVectors)
.withVectorFieldName(field2Name)
.addOutField(field4Name)
.build();
R<SearchResults> searchR = client.search(searchParam);
Assertions.assertEquals(R.Status.Success.getCode(), searchR.getStatus().intValue());
SearchResultsWrapper results = new SearchResultsWrapper(searchR.getData().getResults());
for (int i = 0; i < targetVectors.size(); ++i) {
List<SearchResultsWrapper.IDScore> scores = results.getIDScore(i);
System.out.println("The result of No." + i + " target vector:");
for (int k = 0; k < scores.size(); ++k) {
SearchResultsWrapper.IDScore score = scores.get(k);
System.out.println("ID: " + score.getStrID() + " Distance:" + score.getScore());
}
}
If your primary key is Long type, the id is score.getLongID()
.
If your primary key is Varchar type, the id is score.getStrID()
.