milvus-io/milvus-sdk-java

io.milvus.exception.IllegalResponseException: Result ids is illegal

Closed this issue · 6 comments

hi, 想问下milvus 2.1.0 java检索时有时会报io.milvus.exception.IllegalResponseException: Result ids is illegal
at io.milvus.response.SearchResultsWrapper.getIDScore(SearchResultsWrapper.java:95)
这个bug的原因?

I'm seeing this error as well. @chenzk1993 did you happen to identify the root cause?

did you try latest java SDK?

which is 2.2.5, use milvus version 2.2.8

@xiaofan-luan Yes, I'm using managed Milvus (Zilliz) and the latest Java SDK version.

Some additional information that might help narrow down the cause:

  • The collections we are searching are very small right now (my team is building some demos and POCs to familiarize ourselves with Milvus, so we are keeping our dataset size small for the time being).
  • We are performing hybrid searches

The exception is being thrown when calling the SearchResultsWrapper.getIDScore() method

    public List<IDScore> getIDScore(int indexOfTarget) throws ParamException, IllegalResponseException {
        Position position = getOffsetByIndex(indexOfTarget);

        long offset = position.getOffset();
        long k = position.getK();
        if (offset + k > results.getScoresCount()) {
            throw new IllegalResponseException("Result scores count is wrong");
        }

        List<IDScore> idScore = new ArrayList<>();

        IDs ids = results.getIds();
        if (ids.hasIntId()) {
            LongArray longIDs = ids.getIntId();
            if (offset + k > longIDs.getDataCount()) {
                throw new IllegalResponseException("Result ids count is wrong");
            }

            for (int n = 0; n < k; ++n) {
                idScore.add(new IDScore("", longIDs.getData((int)offset + n), results.getScores((int)offset + n)));
            }
        } else if (ids.hasStrId()) {
            StringArray strIDs = ids.getStrId();
            if (offset + k > strIDs.getDataCount()) {
                throw new IllegalResponseException("Result ids count is wrong");
            }

            for (int n = 0; n < k; ++n) {
                idScore.add(new IDScore(strIDs.getData((int)offset + n), 0, results.getScores((int)offset + n)));
            }
        } else {
            throw new IllegalResponseException("Result ids is illegal"); <-------- Exception originates here
        }

        return idScore;
    }
yhmo commented

Refer to the example:

List<SearchResultsWrapper.IDScore> scores = wrapper.getIDScore(i);

yhmo commented

The exception "Result ids is illegal" is usually thrown when user performs a search to an empty collection.
I have made a change to remove the exception, it will return an empty list instead of exception.

The original code:

      } else {
           throw new IllegalResponseException("Result ids is illegal"); 
       }

After the change:

        } else {
            return idScores;
        }

This change will be available in sdk version v2.3.3/v2.2.15, close this issue as well.