[Milvus] upsert는 auto_id를 모름

yoonene·2025년 2월 13일

항상 RDB로 키를 만들고 Milvus가 그 키값을 사용하도록 만들다가
오랜만에 auto_id로 데이터를 입력하려고 시도했다.

그런데 이런 에러가 났다.

pymilvus.exceptions.DataNotMatchException: <DataNotMatchException: (code=1, message=The data doesn't match with schema fields, expect 5 list, got 4)>

id 필드를 제외한 4개만 들어가는 게 맞는데 id값도 기대하는 것이다.

원인

insert가 아닌 upsert를 썼기 때문!
upsert는 특정 id에 대해 입력을 하게 되면 해당 값을 새로 들어온 값으로 덮어씌울 수 있다. update하여 insert 가능한 기능!
따라서 id 값이 필수로 요구되는 것이었다.

해결

collection.upsert() -> collection.insert()로 수정

profile
NLP Researcher / Information Retrieval / Search

0개의 댓글