diff --git a/src/mongoose/sanitizeFormattedValue.ts b/src/mongoose/sanitizeFormattedValue.ts index e49fd0791e..102ba11be4 100644 --- a/src/mongoose/sanitizeFormattedValue.ts +++ b/src/mongoose/sanitizeFormattedValue.ts @@ -98,7 +98,7 @@ export const sanitizeQueryValue = (schemaType: SchemaType, path: string, operato if (operator === 'like' && typeof formattedValue === 'string') { const words = formattedValue.split(' '); const regex = words.reduce((pattern, word, i) => { - return `${pattern}(?=.*\\b${word}\\b)${i + 1 === words.length ? '.+' : ''}`; + return `${pattern}(?=.*\\b${word}.*\\b)${i + 1 === words.length ? '.+' : ''}`; }, ''); formattedValue = { $regex: new RegExp(regex), $options: 'i' };