Skip to content

Commit

Permalink
Allow * and _ characters in Search AST 'word's (#1058)
Browse files Browse the repository at this point in the history
* Allow * and _ characters in Search AST 'word's

* changelog
  • Loading branch information
chandlerprall authored Aug 6, 2018
1 parent b98ab5b commit 4f3746b
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
- Added `spacesApp` logo to `EuiIcon` set ([#1065](https://github.com/elastic/eui/pull/1065))
- Added `!default` to border SASS props ([#1079](https://github.com/elastic/eui/pull/1079))
- Added `repositionOnScroll` prop to `EuiPopover` which enables repositioning the popover when the window is scrolled. ([#1064](https://github.com/elastic/eui/pull/1064))
- Allow `_` and `*` characters to be used in `EuiSearchBar` query terms ([#1058](https://github.com/elastic/eui/pull/1058))

**Bug fixes**

Expand Down
2 changes: 1 addition & 1 deletion src/components/search_bar/query/default_syntax.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ word
wordChar
= alnum
/ [-]
/ [-_*]
/ escapedChar
escapedChar
Expand Down
32 changes: 32 additions & 0 deletions src/components/search_bar/query/default_syntax.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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`;
Expand Down

0 comments on commit 4f3746b

Please sign in to comment.