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

Kibana query language autocomplete #15945

Merged
merged 193 commits into from
Mar 22, 2018
Merged

Conversation

lukasolson
Copy link
Member

@lukasolson lukasolson commented Jan 10, 2018

Replaces #14523.
Closes #12315.
Relies on #17069.

This PR adds autocomplete functionality to the simplified Kibana query language. It will autocomplete field names, operators, values, and conjunctions.

Value suggestions can be turned off using the same flag to turn off filter editor value suggestions (filterEditor:suggestValues).

mar-21-2018 16-26-35

@lukasolson lukasolson added :Discovery Feature:Query Bar Querying and query bar features v7.0.0 labels Jan 10, 2018
@lukasolson lukasolson self-assigned this Jan 10, 2018
@lukasolson lukasolson mentioned this pull request Jan 10, 2018
3 tasks
}

function resolver(query, field) {
return `${query}/${field.name}`;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this include the index pattern id as well? Otherwise I think two different index patterns with a field that happens to have a matching name could get stale suggestions.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Totally should

@Bargs
Copy link
Contributor

Bargs commented Mar 21, 2018

Pending a green CI, this looks great to me!

Copy link
Contributor

@snide snide left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good luck and godspeed. 👍

@elasticmachine
Copy link
Contributor

💔 Build Failed

Copy link
Contributor

@w33ble w33ble left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@elasticmachine
Copy link
Contributor

💔 Build Failed

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

@lukasolson lukasolson merged commit 0f00c23 into elastic:master Mar 22, 2018
lukasolson added a commit that referenced this pull request Mar 22, 2018
* First stab at refactoring typeahead

* Don't double submit on enter

* Add item templating

* Introduce simple kuery language

* Rename to kql and add modules

* Update KQL syntax

* Automatically insert matching pairs

* Don't match quotes after alphanumeric chars

* Get field and value suggestions

* Remove accidental changes

* Remove unnecessary test

* Don't submit on enter

* Fix typeahead

* Suggest matching recent searches

* Suggest operators

* Suggest conjunctions

* Use template, separate suggestions into separate modules

* Whoops, add this module back

* Add clarifying comment

* Fix history log key

* Don't update suggestions on every key press

* Fix key handling

* Update terminology to be clearer

* Fix typo

* Simplify building of nodes

* Don't always hide on submit

* Check items exists

* Add icon directive which wraps EuiIcon.

* kql design start

* remove comment bits

* Simplify select next/prev and reset selected on hide/backspace

* Add test

* Put persistedLog on scope so it can be tested

* Fix typos

* Build up AST for sublist by returning functions that take a field name

* Remove single quoted strings and add double quote to special characters

* Build nodes with arg nodes instead of args themselves

* Add support for exact phrase search for quoted values

* Update typeahead items when language changes

* Finish that work I didn't do in the last commit

* This commit makes Bargs very happy cuz it does a lot

* Add wildcard field support to range query

* Remove range support for wildcard values

* Remove KQL as a separate language

Updates kuery to use KQL's grammar. This will lead to a smoother
transition for both us and Kuery users. We mainly added KQL as a
separate language so that we could notify Kuery users that the syntax
had changed. I realized we could do the same by trying to parse their
query strings with the old grammar if the new grammar fails, and if the
old grammar parses successfully we can display an error message with a
link to the docs describing the syntax changes. Since Kuery now uses the
more simple KQL syntax, I've also re-enabled the filter bar when Kuery
is selected.

* Fix typeahead behavior

* Update conjunctions

* Use scope apply

* Suggest conjunctions after ranges

* Support strings in wildcard node constructor and add tests for wildcard node

* test updates

* Removing unused serializeStyle and toKueryExpression, updating tests

* Fix functional test

* Fix typo

* Show fields that match in any part of the name

* Alter order of operators

* Preserve focus after selecting by click

* Ports tests for `fromKueryExpression` to `fromKqlExpression`

* More KQL syntax tests

* Suggest conjunctions after ranges

* Fix suggestions inside parens

* fromLiteralExpression tests

* remove serializeStyle arguments which no longer exist in the function definition

* tests for getFields

* Case insensitive search for field names

* update tests for is.js

* add wildcard fieldname test for range.js

* Fix removed div

* Fix line spacing for autocomplete suggestions

* Fix conjunction suggestions with escaped preceding literals

* Escape special characters in fields and values

* Don't suggest the value that's already selected

* Update icons

* Sort prefix first

* Simplify cursor detection and suggest booleans

* Use quotes for suggested values

* get rid of references to KQL

* Don't show errors from parsing

* That didn't even exist

* Use config to determine if values are suggested

* Update suggestions on home/end

* remove hack

* Update reference to kql

* Suggestions for quoted values

* Clean up grammar

* Better support for cursor inside spaces

* Create grunt task to generate parsers from peg files

* Simplify wildcard handling

* Don't filter out the exact fields/values

* Update parsing modules

* Fix peg task

* Make operator syntax more visible

* Update OR verbiage

* Simplify and improve match pairs

* Revert "Simplify wildcard handling"

This reverts commit 915861b.

* Support escaped backslashes inside quoted strings

* Support escaped keywords

* Remove lodash dependency cuz w33ble

* Escape user input and fix conjunction description

* Clear suggestions after submitting

* Fix insertion of suggestion to account for selection

* Remove unnecessary?

* Remove extraneous file

* Better name for method

* Move functions out of event handler

* Don't wrap result in promise

* Don't show kuery suggestions for lucene

* some cleanup and polish for kql autocomplete

* Omit description completely for values

* Don't suggest and/or for quoted strings that end in spaces

* Submit recent search suggestions on select

* Scroll selected suggestion into view

* Better handling of key events and hiding typeahead

* Update suggestions to work in other apps with multiple index patterns

* Only update suggestions if not submitting

* Hide suggestions on focus

* Simplify wildcard (again)

* Fix console error

* Remove references to kql

* Fix match pairs so that suggestions occur with cursor in correct place

* Memoize value suggestions

* Debounce model updates

* Add tests for suggestion providers

* Add setting and docs

* Add custom error, helper for detecting leading wildcards, and check for
leading wildcards in the Value rule of the grammar.

* Better handling of suggestion clicks

* Dedup suggestions

* Sort keywords first

* Fix value suggestions memoizing

* Check if query exists

* Reduce size of dialog and fix ranges

* Create grunt task to generate parsers from peg files

* Lazy load typeahead items

* Fix wildcard tests

* Fix value suggestion tests

* Fix typeahead tests

* Fix value suggestion memoize resolver

* Leave comment

* Add a ttl for the value suggestion resolver

* Move grunt config to config/

* Bargs can suck it

* Fix more tests that bargs broke (and one I did too)

* Fix tests
@lukasolson
Copy link
Member Author

6.x (6.3.0): b665a30

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

@lukasolson lukasolson deleted the kql-autocomplete branch March 27, 2018 21:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants