Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ANN 查询数据 id返回值错误 #745

Open
Stefankeep opened this issue Jan 23, 2024 · 3 comments
Open

ANN 查询数据 id返回值错误 #745

Stefankeep opened this issue Jan 23, 2024 · 3 comments

Comments

@Stefankeep
Copy link

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
Copy link
Contributor

what is your schema of your collection?
is id your primary key field?
is it autoIncrement or user specified

@yhmo
Copy link
Contributor

yhmo commented Jan 29, 2024

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().

@yhmo
Copy link
Contributor

yhmo commented Feb 19, 2024

It is a bug of SearchResultsWrapper.getRowRecords(), which is fixed by #757 and #758.

In fact, getRowRecords() is a wrapper of getIDScore(), it is better to use getIDScore() to get the results.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants