diff --git a/packages/kbn-es-query/src/kuery/functions/is.test.ts b/packages/kbn-es-query/src/kuery/functions/is.test.ts index a19c951c184a9..5b52eff548ed3 100644 --- a/packages/kbn-es-query/src/kuery/functions/is.test.ts +++ b/packages/kbn-es-query/src/kuery/functions/is.test.ts @@ -253,6 +253,29 @@ describe('kuery functions', () => { expect(result).toEqual(expected); }); + test('should create a wildcard query with backslashes properly escaped', () => { + const expected = { + bool: { + should: [ + { + wildcard: { + 'machine.os.keyword': { value: '*\\\\*' }, + }, + }, + ], + minimum_should_match: 1, + }, + }; + const node = nodeTypes.function.buildNode( + 'is', + 'machine.os.keyword', + '*\\\\*' + ) as KqlIsFunctionNode; + const result = is.toElasticsearchQuery(node, indexPattern); + + expect(result).toEqual(expected); + }); + test('should support scripted fields', () => { const node = nodeTypes.function.buildNode( 'is', diff --git a/packages/kbn-es-query/src/kuery/functions/is.ts b/packages/kbn-es-query/src/kuery/functions/is.ts index 55bce74973741..46a6acfc56ff9 100644 --- a/packages/kbn-es-query/src/kuery/functions/is.ts +++ b/packages/kbn-es-query/src/kuery/functions/is.ts @@ -159,7 +159,7 @@ export function toElasticsearchQuery( ? { wildcard: { [field.name]: { - value, + value: wildcard.toQueryStringQuery(valueArg), ...(typeof config.caseInsensitive === 'boolean' && { case_insensitive: config.caseInsensitive, }),