Merge pull request #34284 from overleaf/em-library-highlight-adjustments

fix(library): highlight word prefixes in search results

GitOrigin-RevId: 5457ea1460c442ba33f9042c1e2fc4cd2b9a5e54
This commit is contained in:
Eric Mc Sween
2026-06-09 08:07:27 +00:00
committed by Copybot
parent ad9da31252
commit 595e67973b
@@ -0,0 +1,45 @@
import Helpers from './lib/helpers.mjs'
const tags = ['saas']
const oldIndexes = [
{
key: { userId: 1, searchKey: 1 },
name: 'userId_1_searchKey_1',
collation: { locale: 'en', strength: 1 },
},
{
key: { userId: 1, 'fields.searchValue': 1, 'fields.name': 1 },
name: 'userId_1_fields.searchValue_1_fields.name_1',
collation: { locale: 'en', strength: 1 },
},
]
const newIndexes = [
{
key: { userId: 1, searchKey: 1 },
name: 'userId_1_searchKey_1',
},
{
key: { userId: 1, 'fields.searchValue': 1, 'fields.name': 1 },
name: 'userId_1_fields.searchValue_1_fields.name_1',
},
]
const migrate = async client => {
const { db } = client
await Helpers.dropIndexesFromCollection(db.libraryReferences, oldIndexes)
await Helpers.addIndexesToCollection(db.libraryReferences, newIndexes)
}
const rollback = async client => {
const { db } = client
await Helpers.dropIndexesFromCollection(db.libraryReferences, newIndexes)
await Helpers.addIndexesToCollection(db.libraryReferences, oldIndexes)
}
export default {
tags,
migrate,
rollback,
}