Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow * and _ characters in Search AST 'word's #1058

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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