mirror of
https://github.com/danny-avila/LibreChat.git
synced 2026-01-02 00:28:51 +01:00
🔧 fix: Incorrect count query in meilisearch sync (#11157)
could lead to incorrect counts during sync process and documents being out of sync
This commit is contained in:
parent
f9501d2a42
commit
bed1923990
2 changed files with 24 additions and 3 deletions
|
|
@ -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(),
|
||||
|
|
|
|||
|
|
@ -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 };
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue