1. Learn
  2. /
  3. 课程
  4. /
  5. 使用 OpenAI API 的 Embeddings 入门

Connected

道练习

在集合中更新与删除条目

把文档存入向量数据库后,您仍然可以对集合进行增补或更新已有条目。

在本练习中,已为您提供了存放在 new_data 中的两条新的 Netflix 标题:

[{"id": "s1001", "document": "Title: Cats & Dogs (Movie)\nDescription: A look at the top-secret, high-tech espionage war going on between cats and dogs, of which their human owners are blissfully unaware."},
 {"id": "s6884", "document": 'Title: Goosebumps 2: Haunted Halloween (Movie)\nDescription: Three teens spend their Halloween trying to stop a magical book, which brings characters from the "Goosebumps" novels to life.\nCategories: Children & Family Movies, Comedies'}]

根据这些 ID 是否已在集合中存在,您将把它们添加到数据库或对其进行更新。

说明

100 XP
  • 从 new_data 中提取 ID 和文档,使用单个方法在 netflix_titles 集合中对已存在的条目执行更新,对不存在的条目执行新增。
  • 添加/更新完成后,删除 ID 为 's95' 的条目。