Skip to content

Enhanced ChatGPT Clone: Features Agents, MCP, Skills, DeepSeek, Anthropic, AWS, OpenAI, Responses API, Azure, Groq, o1, GPT-5, Mistral, OpenRouter, Vertex AI, Gemini, Artifacts, AI model switching, message search, Code Interpreter, langchain, DALL-E-3, OpenAPI Actions, Functions, Secure Multi-User Auth, Presets, open-source for self-hosting. Active

🔧 fix: Incorrect count query in meilisearch sync (#11157)

Andrei Blizorukovbed1923990da
diff --git a/packages/data-schemas/src/models/plugins/mongoMeili.spec.ts b/packages/data-schemas/src/models/plugins/mongoMeili.spec.ts
index 6455bba105..0bf3ab75ef 100644
--- a/packages/data-schemas/src/models/plugins/mongoMeili.spec.ts
+++ b/packages/data-schemas/src/models/plugins/mongoMeili.spec.ts
@@ -61,6 +61,17 @@ describe('Meilisearch Mongoose plugin', () => {
expect(mockAddDocuments).toHaveBeenCalled();
});
+ test('saving conversation indexes with expiredAt=null w/ meilisearch', async () => {
+ await createConversationModel(mongoose).create({
+ conversationId: new mongoose.Types.ObjectId(),
+ user: new mongoose.Types.ObjectId(),
+ title: 'Test Conversation',
+ endpoint: EModelEndpoint.openAI,
+ expiredAt: null,
+ });
+ expect(mockAddDocuments).toHaveBeenCalled();
+ });
+
test('saving TTL conversation does NOT index w/ meilisearch', async () => {
await createConversationModel(mongoose).create({
conversationId: new mongoose.Types.ObjectId(),
@@ -82,6 +93,17 @@ describe('Meilisearch Mongoose plugin', () => {
expect(mockAddDocuments).toHaveBeenCalled();
});
+ test('saving messages with expiredAt=null indexes w/ meilisearch', async () => {
+ await createMessageModel(mongoose).create({
+ messageId: new mongoose.Types.ObjectId(),
+ conversationId: new mongoose.Types.ObjectId(),
+ user: new mongoose.Types.ObjectId(),
+ isCreatedByUser: true,
+ expiredAt: null,
+ });
+ expect(mockAddDocuments).toHaveBeenCalled();
+ });
+
test('saving TTL messages does NOT index w/ meilisearch', async () => {
await createMessageModel(mongoose).create({
messageId: new mongoose.Types.ObjectId(),
diff --git a/packages/data-schemas/src/models/plugins/mongoMeili.ts b/packages/data-schemas/src/models/plugins/mongoMeili.ts
index ea7689d22d..2d56303395 100644
--- a/packages/data-schemas/src/models/plugins/mongoMeili.ts
+++ b/packages/data-schemas/src/models/plugins/mongoMeili.ts
@@ -183,9 +183,8 @@ const createMeiliMongooseModel = ({
);
// Build query with resume capability
- const query: FilterQuery<unknown> = {
- expiredAt: { $exists: false }, // Do not sync TTL documents
- };
+ // Do not sync TTL documents
+ const query: FilterQuery<unknown> = { expiredAt: null };
if (options?.resumeFromId) {
query._id = { $gt: options.resumeFromId };
}