Skip to content

Commit

Permalink
fixing kql issue
Browse files Browse the repository at this point in the history
  • Loading branch information
ppisljar committed Mar 16, 2021
1 parent 3de7093 commit 8776573
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
11 changes: 10 additions & 1 deletion src/plugins/data/common/search/expressions/query_to_ast.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,21 @@
import { queryToAst } from './query_to_ast';

describe('queryToAst', () => {
it('returns an object with the correct structure', () => {
it('returns an object with the correct structure for lucene queies', () => {
const actual = queryToAst({ language: 'lucene', query: { country: 'US' } });
expect(actual).toHaveProperty('functions');
expect(actual.functions[0]).toHaveProperty('name', 'lucene');
expect(actual.functions[0]).toHaveProperty('arguments', {
q: ['{"country":"US"}'],
});
});

it('returns an object with the correct structure for kql queies', () => {
const actual = queryToAst({ language: 'kuery', query: 'country:US' });
expect(actual).toHaveProperty('functions');
expect(actual.functions[0]).toHaveProperty('name', 'kql');
expect(actual.functions[0]).toHaveProperty('arguments', {
q: ['country:US'],
});
});
});
2 changes: 1 addition & 1 deletion src/plugins/data/common/search/expressions/query_to_ast.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { ExpressionFunctionKql } from './kql';
import { ExpressionFunctionLucene } from './lucene';

export const queryToAst = (query: Query) => {
if (query.language === 'kql') {
if (query.language === 'kuery') {
return buildExpression([
buildExpressionFunction<ExpressionFunctionKql>('kql', { q: query.query as string }),
]);
Expand Down

0 comments on commit 8776573

Please sign in to comment.