From 6aaaac8aa6cb407b8a0d68b3e22ca450862b1fad Mon Sep 17 00:00:00 2001 From: Chandler Prall Date: Mon, 30 Jul 2018 12:03:43 -0600 Subject: [PATCH 1/2] Allow * and _ characters in Search AST 'word's --- .../search_bar/query/default_syntax.js | 2 +- .../search_bar/query/default_syntax.test.js | 32 +++++++++++++++++++ 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/src/components/search_bar/query/default_syntax.js b/src/components/search_bar/query/default_syntax.js index 0f6ca5835df..5d7ba1bcf76 100644 --- a/src/components/search_bar/query/default_syntax.js +++ b/src/components/search_bar/query/default_syntax.js @@ -127,7 +127,7 @@ word wordChar = alnum - / [-] + / [-_*] / escapedChar escapedChar diff --git a/src/components/search_bar/query/default_syntax.test.js b/src/components/search_bar/query/default_syntax.test.js index c74b710a3d6..61251fb79a9 100644 --- a/src/components/search_bar/query/default_syntax.test.js +++ b/src/components/search_bar/query/default_syntax.test.js @@ -661,6 +661,38 @@ describe('defaultSyntax', () => { expect(clause.value).toBe('truest'); }); + describe('wordChar', () => { + test('alphanumeric characters', () => { + const ast = defaultSyntax.parse('logstash'); + const clauses = ast.getTermClauses(); + expect(clauses).toEqual([{ + type: 'term', + value: 'logstash', + match: 'must', + }]); + }); + + test('escaped characters', () => { + const ast = defaultSyntax.parse('\\-'); + const clauses = ast.getTermClauses(); + expect(clauses).toEqual([{ + type: 'term', + value: '-', + match: 'must', + }]); + }); + + test('special characters', () => { + const ast = defaultSyntax.parse('*_-'); + const clauses = ast.getTermClauses(); + expect(clauses).toEqual([{ + type: 'term', + value: '*_-', + match: 'must', + }]); + }); + }); + test('number range expressions', () => { const query = `num1>6 -num2>=8 num3<4 -num4<=2`; From 21fb54534873a1a1f61806765f4ff55296f1ee5c Mon Sep 17 00:00:00 2001 From: Chandler Prall Date: Mon, 30 Jul 2018 12:06:50 -0600 Subject: [PATCH 2/2] changelog --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 783fee92995..f2d1a9e26c2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,7 @@ ## [`master`](https://github.com/elastic/eui/tree/master) +- Allow `_` and `*` characters to be used in `EuiSearchBar` query terms ([#1058](https://github.com/elastic/eui/pull/1058)) + **Bug fixes** - Fixed `EuiXYChart` responsive resize in a flexbox layout ([#1041](https://github.com/elastic/eui/pull/1041))