-
Notifications
You must be signed in to change notification settings - Fork 844
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
[Search Bar/Query/Default Syntax] Parser support for "recognizedFields" options #7960
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
4778c74
[Search Bar/Query/Default Syntax] Support for allowedFields in parse …
tsullivan c5a8707
add changelog
tsullivan 99c447c
Merge branch 'main' into eui/parse-query-update
tsullivan e10c801
Relocate new field to box.schema.recognizedFields
tsullivan 0faad32
Merge branch 'main' into eui/parse-query-update
tsullivan bcdfdb7
Merge branch 'eui/parse-query-update' of github.com:tsullivan/eui int…
tsullivan 707a9d0
remove stray
tsullivan 76b1010
[PR feedback] changelog
cee-chen 5e92233
[PR feedback] syntax nit
cee-chen File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
- Updated `EuiSearchBar`'s optional `box.schema` prop with a new `recognizedFields` configuration. This allows specifying the phrases that will be parsed as field clauses |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the ampersand doing here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@pugnascotia
Unfortunately, PegJS documentation is no longer available directly, but it can be found here: http://web.archive.org/web/20240102234657/https://pegjs.org/documentation. Take a look under "Parsing Expression Types"
In other words, the
&{ return !hasRecognizedFields || recognizedFields.includes(id); }
is a predicate check that determines whether the rule succeeds or fails. This check ensures that ifhasRecognizedFields
is truthy, then there is a restriction that the identifier must be included in therecognizedFields
array to be treated as a field name. If the predicate passes, then the identifier is parsed as a field name. If the predicate does not pass, then thefieldName
match is failed and the parser falls back to using theidentifier
rule.By the way, I used Microsoft Copilot to explain this to me and help me with updating the parsing rules. If it wasn't for that, I am sure I would not have been able to figure it out.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I checked the docs as they appear in source control, to double-check:
https://github.com/pegjs/pegjs/blob/master/docs/grammar/parsing-expression-types.md#--predicate-
So this looks good.