feat: operation index (#5056)

* feat: operation index

* fix: delete update vector

* perf: Clear invalid data

* perf: index

* perf: cleare invalid data

* index
This commit is contained in:
Archer
2025-06-18 00:46:31 +08:00
committed by GitHub
parent 6060543222
commit 6b2ea696c5
8 changed files with 84 additions and 31 deletions

View File

@@ -23,6 +23,12 @@ try {
ImageSchema.index({ type: 1 });
// delete related img
ImageSchema.index({ teamId: 1, 'metadata.relatedId': 1 });
// Cron clear invalid img
ImageSchema.index(
{ createTime: 1 },
{ partialFilterExpression: { 'metadata.relatedId': { $exists: true } } }
);
} catch (error) {
console.log(error);
}

View File

@@ -132,6 +132,12 @@ try {
}
}
);
// Clear invalid image
DatasetCollectionSchema.index({
teamId: 1,
'metadata.relatedImgId': 1
});
} catch (error) {
console.log(error);
}

View File

@@ -103,12 +103,14 @@ try {
});
// Recall vectors after data matching
DatasetDataSchema.index({ teamId: 1, datasetId: 1, collectionId: 1, 'indexes.dataId': 1 });
DatasetDataSchema.index({ updateTime: 1 });
// rebuild data
DatasetDataSchema.index({ rebuilding: 1, teamId: 1, datasetId: 1 });
// 为查询 initJieba 字段不存在的数据添加索引
DatasetDataSchema.index({ initJieba: 1, updateTime: 1 });
// Cron clear invalid data
DatasetDataSchema.index({ updateTime: 1 });
} catch (error) {
console.log(error);
}

View File

@@ -6,7 +6,7 @@ import {
TeamMemberCollectionName
} from '@fastgpt/global/support/user/team/constant';
export const OperationLogCollectionName = 'operationLog';
export const OperationLogCollectionName = 'operationLogs';
const OperationLogSchema = new Schema({
tmbId: {
@@ -34,6 +34,9 @@ const OperationLogSchema = new Schema({
}
});
OperationLogSchema.index({ teamId: 1, tmbId: 1, event: 1 });
OperationLogSchema.index({ timestamp: 1 }, { expireAfterSeconds: 14 * 24 * 60 * 60 }); // Auto delete after 14 days
export const MongoOperationLog = getMongoLogModel<OperationLogSchema>(
OperationLogCollectionName,
OperationLogSchema