MongoIndexUtils
public final class MongoIndexUtils
源码Source
io/agentscope/extensions/mongodb/MongoIndexUtils.java:35–170Mongo 索引 Utils,在多次调用之间保存和恢复会话与记忆数据。位于 io.agentscope.extensions.mongodb 包。核心成员包括 createIndexWithMigration。
Utility for creating MongoDB indexes with automatic migration on
IndexOptionsConflict (error code 85).
When an existing index has conflicting options (e.g. TTL value changed), this utility
uses listIndexes() to find the actual index name by key pattern — not a
guessed default name — so it works even when DBAs renamed the index.
方法摘要Method Summary
| 方法Method | 说明Description |
|---|---|
public static void createIndexWithMigration(MongoCollection<Document> collection, Bson indexKeys, IndexOptions options)static | 创建 `createIndexWithMigration`。 Creates an index, migrating if an existing index has conflicting options (error 85). |
方法详情Method Detail
createIndexWithMigration
public static void createIndexWithMigration(MongoCollection<Document> collection, Bson indexKeys, IndexOptions options)
static
创建 createIndexWithMigration。
Creates an index, migrating if an existing index has conflicting options (error 85).
参数Parameters
| 名称Name | 类型Type | 说明Description |
|---|---|---|
collection | MongoCollection<Document> | MongoDB 集合。the MongoDB collection |
indexKeys | Bson | 索引密钥(类型 `Bson`)。the index key specification (e.g. `Indexes.ascending("field")`) |
options | IndexOptions | 选项(类型 `IndexOptions`)。the index options (e.g. TTL, sparse, unique) |
源码Source
io/agentscope/extensions/mongodb/MongoIndexUtils.java:63–73