AS AgentScopeAPI 手册 / API Reference

MongoIndexUtils

public final class MongoIndexUtils
源码Source io/agentscope/extensions/mongodb/MongoIndexUtils.java:35–170

Mongo 索引 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
collectionMongoCollection<Document>MongoDB 集合。the MongoDB collection
indexKeysBson索引密钥(类型 `Bson`)。the index key specification (e.g. `Indexes.ascending("field")`)
optionsIndexOptions选项(类型 `IndexOptions`)。the index options (e.g. TTL, sparse, unique)
源码Source io/agentscope/extensions/mongodb/MongoIndexUtils.java:63–73
基于官方固定版本源码静态生成Generated from pinned official sources · Python 2.0.11 · Java 2.0.4
签名与文档为静态抽取;如有疑问请以源码为准。Signatures and docs are extracted statically; verify against the source when in doubt.