diff --git a/x-pack/plugins/lens/public/datasources/form_based/operations/definitions/formula/generate.ts b/x-pack/plugins/lens/public/datasources/form_based/operations/definitions/formula/generate.ts index a2f94fb437062..b13c3ff261207 100644 --- a/x-pack/plugins/lens/public/datasources/form_based/operations/definitions/formula/generate.ts +++ b/x-pack/plugins/lens/public/datasources/form_based/operations/definitions/formula/generate.ts @@ -79,7 +79,7 @@ export function generateFormula( } previousFormula += (previousColumn.filter.language === 'kuery' ? 'kql=' : 'lucene=') + - `'${previousColumn.filter.query.replace(/'/g, `\\'`)}'`; // replace all + `'${previousColumn.filter.query.replace(/\\/g, '\\\\').replace(/'/g, `\\'`)}'`; // replace all } if (previousColumn.timeShift) { if (