mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 17:28:26 -04:00
* [KQL] Use cache and other performance improvements * Fix test * Fix jest tests Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com> Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
This commit is contained in:
parent
2d60be9340
commit
f4fae28bda
5 changed files with 846 additions and 196 deletions
File diff suppressed because it is too large
Load diff
|
@ -29,7 +29,7 @@ OrQuery
|
|||
= &{ return errorOnLuceneSyntax; } LuceneQuery
|
||||
/ head:AndQuery tail:(Or query:AndQuery { return query; })+ {
|
||||
const nodes = [head, ...tail];
|
||||
const cursor = nodes.find(node => node.type === 'cursor');
|
||||
const cursor = parseCursor && nodes.find(node => node.type === 'cursor');
|
||||
if (cursor) return cursor;
|
||||
return buildFunctionNode('or', nodes);
|
||||
}
|
||||
|
@ -38,7 +38,7 @@ OrQuery
|
|||
AndQuery
|
||||
= head:NotQuery tail:(And query:NotQuery { return query; })+ {
|
||||
const nodes = [head, ...tail];
|
||||
const cursor = nodes.find(node => node.type === 'cursor');
|
||||
const cursor = parseCursor && nodes.find(node => node.type === 'cursor');
|
||||
if (cursor) return cursor;
|
||||
return buildFunctionNode('and', nodes);
|
||||
}
|
||||
|
@ -143,7 +143,7 @@ ListOfValues
|
|||
OrListOfValues
|
||||
= head:AndListOfValues tail:(Or partial:AndListOfValues { return partial; })+ {
|
||||
const nodes = [head, ...tail];
|
||||
const cursor = nodes.find(node => node.type === 'cursor');
|
||||
const cursor = parseCursor && nodes.find(node => node.type === 'cursor');
|
||||
if (cursor) {
|
||||
return {
|
||||
...cursor,
|
||||
|
@ -157,7 +157,7 @@ OrListOfValues
|
|||
AndListOfValues
|
||||
= head:NotListOfValues tail:(And partial:NotListOfValues { return partial; })+ {
|
||||
const nodes = [head, ...tail];
|
||||
const cursor = nodes.find(node => node.type === 'cursor');
|
||||
const cursor = parseCursor && nodes.find(node => node.type === 'cursor');
|
||||
if (cursor) {
|
||||
return {
|
||||
...cursor,
|
||||
|
@ -213,7 +213,7 @@ Literal "literal"
|
|||
= QuotedString / UnquotedLiteral
|
||||
|
||||
QuotedString
|
||||
= '"' prefix:QuotedCharacter* cursor:Cursor suffix:QuotedCharacter* '"' {
|
||||
= &{ return parseCursor; } '"' prefix:QuotedCharacter* cursor:Cursor suffix:QuotedCharacter* '"' {
|
||||
const { start, end } = location();
|
||||
return {
|
||||
type: 'cursor',
|
||||
|
@ -234,7 +234,7 @@ QuotedCharacter
|
|||
/ !Cursor char:[^"] { return char; }
|
||||
|
||||
UnquotedLiteral
|
||||
= prefix:UnquotedCharacter* cursor:Cursor suffix:UnquotedCharacter* {
|
||||
= &{ return parseCursor; } prefix:UnquotedCharacter* cursor:Cursor suffix:UnquotedCharacter* {
|
||||
const { start, end } = location();
|
||||
return {
|
||||
type: 'cursor',
|
||||
|
@ -266,7 +266,7 @@ Wildcard
|
|||
= '*' { return wildcardSymbol; }
|
||||
|
||||
OptionalSpace
|
||||
= prefix:Space* cursor:Cursor suffix:Space* {
|
||||
= &{ return parseCursor; } prefix:Space* cursor:Cursor suffix:Space* {
|
||||
const { start, end } = location();
|
||||
return {
|
||||
type: 'cursor',
|
||||
|
|
|
@ -66,17 +66,13 @@ describe('kql syntax errors', () => {
|
|||
it('should throw an error for unescaped quotes in a quoted string', () => {
|
||||
expect(() => {
|
||||
fromKueryExpression('foo:"ba "r"');
|
||||
}).toThrow(
|
||||
'Expected AND, OR, end of input, whitespace but "r" found.\n' + 'foo:"ba "r"\n' + '---------^'
|
||||
);
|
||||
}).toThrow('Expected AND, OR, end of input but "r" found.\n' + 'foo:"ba "r"\n' + '---------^');
|
||||
});
|
||||
|
||||
it('should throw an error for unescaped special characters in literals', () => {
|
||||
expect(() => {
|
||||
fromKueryExpression('foo:ba:r');
|
||||
}).toThrow(
|
||||
'Expected AND, OR, end of input, whitespace but ":" found.\n' + 'foo:ba:r\n' + '------^'
|
||||
);
|
||||
}).toThrow('Expected AND, OR, end of input but ":" found.\n' + 'foo:ba:r\n' + '------^');
|
||||
});
|
||||
|
||||
it('should throw an error for range queries missing a value', () => {
|
||||
|
|
|
@ -12,6 +12,7 @@ module.exports = {
|
|||
dest: 'src/plugins/data/common/es_query/kuery/ast/_generated_/kuery.js',
|
||||
options: {
|
||||
allowedStartRules: ['start', 'Literal'],
|
||||
cache: true,
|
||||
},
|
||||
},
|
||||
timelion_chain: {
|
||||
|
|
|
@ -286,9 +286,8 @@ export default function ({ getService }: FtrProviderContext) {
|
|||
expect(resp.body).to.eql({
|
||||
error: 'Bad Request',
|
||||
message:
|
||||
'KQLSyntaxError: Expected AND, OR, end of input, ' +
|
||||
'whitespace but "<" found.\ndashboard.attributes.title:foo' +
|
||||
'<invalid\n------------------------------^: Bad Request',
|
||||
'KQLSyntaxError: Expected AND, OR, end of input but "<" found.\ndashboard.' +
|
||||
'attributes.title:foo<invalid\n------------------------------^: Bad Request',
|
||||
statusCode: 400,
|
||||
});
|
||||
}));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue