-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
Add Lucene query syntax help #10928
Add Lucene query syntax help #10928
Conversation
With this implementation, users won't be able to reference help if they've already started building the query. I don't think that's a deal breaker upfront, but it's something we should address at some point. This certainly still has value as-is, though. |
@cjcenizal I could use some advice on how to best go about getting the design closer to the mockup you posted. I applied some of the kui styles you suggested but I think there's still some room for improvement. |
@epixa my long term plan to address that is to make the help and suggestions more dynamic, similar to slack's search bar. In the short term I'm assuming if someone wants to copy one of the these static examples, they'll copy paste rather than try to type it in manually. That was just my line of thinking at least. |
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.
Nice work! Just a couple suggestions.
src/ui/public/query_help/index.html
Outdated
@@ -0,0 +1,82 @@ | |||
<div class="queryHelp"> |
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.
Here are some tweaks we can make to polish the UI a bit:
<div class="queryHelp">
<h3 class="kuiSubTitle kuiVerticalRhythm">
Query Tips
</h3>
<p class="kuiText kuiVerticalRhythm">
The search bar at the top uses Elasticsearch’s support for Lucene
<a class="kuiLink"
href="http://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-query-string-query.html#query-string-syntax"
target="_blank"
>
Query String syntax
</a>.
</p>
<p class="kuiText kuiVerticalRhythm">
Here are some examples of how the syntax works.
</p>
<table class="kuiTable kuiTable--fluid kuiVerticalRhythm">
<thead>
<tr>
<th class="kuiTableHeaderCell">Example query</th>
<th class="kuiTableHeaderCell">What it will do</th>
</tr>
</thead>
<tbody>
<tr class="kuiTableRow">
<td class="kuiTableRowCell">
<div class="kuiTableRowCell__liner">
200
</div>
</td>
<td class="kuiTableRowCell">
<div class="kuiTableRowCell__liner">
Find requests that contain the number 200, in any field:
</div>
</td>
</tr>
<tr class="kuiTableRow">
<td class="kuiTableRowCell">
<div class="kuiTableRowCell__liner">
status:200
</div>
</td>
<td class="kuiTableRowCell">
<div class="kuiTableRowCell__liner">
Or we can search in a specific field. Find 200 in the status field:
</div>
</td>
</tr>
<tr class="kuiTableRow">
<td class="kuiTableRowCell">
<div class="kuiTableRowCell__liner">
status:[400 TO 499]
</div>
</td>
<td class="kuiTableRowCell">
<div class="kuiTableRowCell__liner">
Find all status codes between 400-499:
</div>
</td>
</tr>
<tr class="kuiTableRow">
<td class="kuiTableRowCell">
<div class="kuiTableRowCell__liner">
status:[400 TO 499] AND extension:PHP
</div>
</td>
<td class="kuiTableRowCell">
<div class="kuiTableRowCell__liner">
Find status codes 400-499 with the extension php:
</div>
</td>
</tr>
<tr class="kuiTableRow">
<td class="kuiTableRowCell">
<div class="kuiTableRowCell__liner">
status:[400 TO 499] AND (extension:php OR extension:html)
</div>
</td>
<td class="kuiTableRowCell">
<div class="kuiTableRowCell__liner">
Or HTML
</div>
</td>
</tr>
</tbody>
</table>
</div>
@@ -5,7 +5,10 @@ | |||
class="typeahead-items" | |||
> | |||
|
|||
<div ng-if="!typeahead.query.length" ng-transclude></div> |
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.
If you remove this ng-if and put the transclude after the suggestions, then users can access the help even when the typeahead is offering suggestions. We might need to figure out a way to let the use collapse/expand the help. I think we could do that in a subsequent PR.
<div
ng-show="typeahead.isVisible()"
ng-mouseenter="typeahead.setMouseover(true);"
ng-mouseleave="typeahead.setMouseover(false);"
class="typeahead-items"
>
<div
ng-if="typeahead.query.length"
ng-repeat="item in typeahead.getItems()"
ng-class="{active: item === typeahead.active}"
ng-click="typeahead.selectItem(item, $event);"
ng-mouseenter="typeahead.activateItem(item);"
class="typeahead-item"
>
{{item}}
</div>
<div ng-transclude></div>
</div>
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 played around with that idea before, I was afraid it might be too noisy. I'm down with it if you think it looks ok though.
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 think it's better than hiding it. It's definitely not perfect though... could use some of @snide's magic.
@cjcenizal I updated the styles and changed the transclude to always be present below the typeahead items.
With Without |
@Bargs I chose I think it's OK to have empty space to the right-side of the table. |
@snide Thoughts on this? ^ |
@cjcenizal Yeah, I'd keep off the full width since that page itself is full width and it'll expand into unreadability. |
Fair enough, re-added. Assuming tests pass, I believe I've taken care of all the outstanding items. |
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.
Just a couple small formatting requests, and then 👍 👍 from me.
@@ -48,7 +47,7 @@ | |||
<span class="fa fa-search" aria-hidden="true"></span> | |||
</button> | |||
</div> | |||
<kbn-typeahead-items></kbn-typeahead-items> | |||
<kbn-typeahead-items><query-help></query-help></kbn-typeahead-items> |
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 internally debated over asking for this because it's kind of nitpicky, but I might as well... can we format this to use indentation to reflect the nested natured of these elements?
<kbn-typeahead-items>
<query-help></query-help>
</kbn-typeahead-items>
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.
Certainly, not a problem. Updated!
@@ -45,7 +44,7 @@ | |||
<span class="fa fa-search" aria-hidden="true"></span> | |||
</button> | |||
</div> | |||
<kbn-typeahead-items></kbn-typeahead-items> | |||
<kbn-typeahead-items><query-help></query-help></kbn-typeahead-items> |
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.
Same here.
@@ -59,7 +58,7 @@ | |||
<span aria-hidden="true" class="fa fa-search"></span> | |||
</button> | |||
</div> | |||
<kbn-typeahead-items></kbn-typeahead-items> | |||
<kbn-typeahead-items><query-help></query-help></kbn-typeahead-items> |
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.
Same here.
@lukasolson mind giving this a quick look as well? |
@@ -28,7 +28,6 @@ | |||
<div class="kuiLocalSearch"> | |||
<input | |||
parse-query | |||
input-focus |
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.
Hmm, I'm not a huge fan of this. Now, when Discover loads, I can't get to work immediately without using my mouse to focus in on the search input.
What if, instead, we put a help icon to the right side of the search, and when you clicked on it, it brought up this same help dialog?
/cc @cjcenizal
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.
Ultimately, if/when #10976 gets in, we could move to something more like how Google Drive does this:
Notice how there's a "Learn More" button in the bottom of the pop-up. Thoughts?
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 don't think removing input-focus
is actually necessary to accomplish the current experience, I just removed it when I was playing around with things. I left it out because I remember this auto-focus came up as something that hurts accessibility in the accessibility study that was done awhile back. If we want to discuss that outside of this PR, I can try putting it back in.
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.
If auto-focus is a critical usability improvement, then I think we should keep it and figure out other ways to address the accessibility concerns, e.g. providing context to screen readers with aria attributes.
FYI @snide is working on some designs this week that incorporate both these changes and the ones in #10976.
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 think ultimately if we do show this help every time the user has focus on the search bar, we should at least have a mechanism to hide it, because I can see it getting in the way, and potentially frustrating for users if they don't want to see the help any more.
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.
To do that I think we'll need to store the user's choice in local or session storage, which we don't have a great way to do in a consistent manner in Kibana at the moment.
The only issues I have with putting a help link in the dropdown added by #10976 is that 1. it will be kind of buried and 2. this help text doesn't relate to the rest of the content of the dropdown. The dropdown manages filters while this help text is about the query bar.
It sounds like the help should be hidden by default, but easy to find. Should we put a help link in or near the query bar?
Or, we could go back to the original implementation that hid the help after the user starts typing. I think there was significantly less risk of that becoming annoying since it wasn't in the user's face any time the query bar had focus.
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.
Fair enough. Let's just stick with the original implementation for now.
Hmm, looks like the query help is sticking around for me even after I start typing. |
@lukasolson yes, it was changed to be persistent at @cjcenizal's request. I can revert it if he's ok with that solution. |
I tried it out, and I think I prefer the persistent behavior. @Bargs this is really awesome! With feature freeze having passed for 5.4, I assume this will have to go into 5.5? |
@tbragin @lukasolson @cjcenizal @snide New update based on our convo: I have to say I quite like it, simple and gets the job done. Let me know what you all think. A couple notes:
|
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 think this is a great improvement!
Don't forget to update the UI Framework examples in https://github.com/elastic/kibana/tree/master/ui_framework/doc_site/src/views/local_nav. Right now they look like this:
@snide Thoughts on the use of em
and various values in the SCSS?
@Bargs what are your thoughts on adding a "don't show me this again" option for power users? I could see this being a bit annoying if you are comfortable with lucense This is a bit minor but any thoughts on how previous queries and this in-line help could play better together? |
Thanks for the reminder @cjcenizal, I didn't know about those files. @alexfrancoeur I removed that inline help, the newest version just provides a link to the docs in the query bar. |
It might be nice to establish a common icon for helping people identify links to helpful resources, but this is definitely a @snide decision. |
You can always make this appear on focus of the input so that it doesn't show until it matters. If you're targeting BI users even partially, id suggest keeping that element there, otherwise people will just assume it's a general google search bar. Id prefer we stop using the "i" buttons when we can. More specifically here because it needs to link to the docs. |
@lukasolson @cjcenizal just pushed some updates. I believe I've covered everything we've talked about. Ready for another review.
|
jenkins, test this |
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.
This is looking great! I have one suggestion for CSS organization and one for improving accessibility.
Also, would you mind updating the UI Framework examples so they demonstrate the new UX of hiding/revealing the link? You just need to add the kuiLocalSearchAssistedInput__assistanceLink
class to the markup in ui_framework/doc_site/src/views/local_nav/local_nav_search.html
.
@@ -28,6 +28,10 @@ | |||
} | |||
} | |||
|
|||
.kuiLocalLuceneSearchInput:focus { | |||
padding-right: 13em; | |||
} |
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'd characterize this as a custom class, specific to the way we're using the LocalSearch components in Discover and elsewhere in Kibana. Looking at it from that perspective, I think it's probably best to rename this to something like localLuceneSearchInput
(reserving the kui prefix for the UI Framework classes), and put it in src/core_plugins/kibana/public/kibana.less
(or somewhere within that directory).
I think the counter-point is that we want to use this help link in every instance of the LocalSearch, but I think we should still draw a line and use the UI Framework to provide generic components and guidance on patterns for using them, and use src
to define more concrete rules on how these generic components are used in Kibana. What do you think @snide ?
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.
Or just more generically name it as a modifier, which can let it still live here and be reused (since it seems pretty generic).
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.
Normally I'd agree, but the 13em padding is really tightly coupled with the length of the string that goes in there, i.e. "Uses Lucene query syntax" is 13em wide.
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.
But it's no biggie, we can keep it here as a modifier. It'd be easy to move if it becomes confusing.
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.
Will other plugins be able to use this class if we put it in src/core_plugins/kibana/public/kibana.less
? If yes, then I think that's fine. If no, it would be nice to keep it somewhere reusable.
By name it as a modifier, do you mean something like kuiLocalSearchInput--lucene
?
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.
If someone disables the Kibana plugin then I guess those styles might not be available. If that's a concern, then how about putting them into ui/public/styles/local_search.less
?
Yep, that uses the correct modifier format. Looks good to me.
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.
Maybe add a comment to the styles noting that 13em is the width of 'Uses Lucene query syntax'
so it isn't just a magic number.
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.
ui/public/styles/local_search.less
sounds fine to me. Just to be clear, which name do you prefer in that file, localLuceneSearchInput
or localSearchInput-lucene
? Or something else?
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.
Let's use the modifier format to indicate how it's related to the base class: kuiLocalSearchInput--lucene
.
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.
@@ -26,7 +26,7 @@ | |||
|
|||
<h3>Refine your query</h3> | |||
<p> | |||
The search bar at the top uses Elasticsearch's support for Lucene <a href="http://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-query-string-query.html#query-string-syntax" target="_blank">Query String syntax</a>. Let's say we're searching web server logs that have been parsed into a few fields. | |||
The search bar at the top uses Elasticsearch's support for Lucene <a ng-href="{{queryDocLinks.luceneQuerySyntax}}" target="_blank">Query String syntax</a>. Let's say we're searching web server logs that have been parsed into a few fields. |
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.
Can you add a kuiLink
class 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.
👍 8d8818e
.kuiLocalSearchAssistedInput__assistanceLink:active { | ||
display: inherit; | ||
} | ||
|
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.
Can we replace lines 31 through 69 with this:
/**
* 1. Visually hide this until the parent is focused, so that it's accessible to screen readers.
*/
.kuiLocalSearchInput:focus {
& ~ .kuiLocalSearchAssistedInput__assistance {
.kuiLocalSearchAssistedInput__assistanceLink {
opacity: 1; /* 1 */
}
}
}
.kuiLocalSearchAssistedInput {
display: flex;
flex: 1 1 100%;
position: relative;
}
/**
* 1. Vertically center the assistance, regardless of its height.
*/
.kuiLocalSearchAssistedInput__assistance {
position: absolute;
right: $globalFormControlHorizontalPadding;
top: 50%; /* 1 */
transform: translateY(-50%); /* 1 */
}
/**
* 1. Visually hide this until it's focused, so that it's accessible to screen readers, and is
* also keyboard-accessible.
*/
.kuiLocalSearchAssistedInput__assistanceLink {
opacity: 0; /* 1 */
&:focus {
opacity: 1; /* 1 */
}
}
These changes will ensure the link is visible to screen readers, and can also be tabbed to by users who are using the keyboard to navigate.
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.
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.
Good point. How about if we change the help to show up on hover as well as focus:
.kuiLocalSearchInput:hover,
.kuiLocalSearchInput:focus {
& ~ .kuiLocalSearchAssistedInput__assistance {
.kuiLocalSearchAssistedInput__assistanceLink {
opacity: 1; /* 1 */
}
}
}
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.
That seems like a weird interaction to me. If the user wants to modify something at the end of their query they're going to mouse over it in order to click the spot they want to edit, but then that spot is going to suddenly disappear under the help link. The only way for them to get to what they wanted at that point is to click another part of the query and shift the cursor with the keyboard. I'd find that infuriating as a user.
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.
It seems like we have that problem anyway:
As long as we hide that link by default, it's going to create a strange interaction when users try to click the text that it invisibly occupies. Maybe we should go back to showing it all the time? @snide what do you think?
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.
You're right, that interaction stinks as well. Unless @snide has any good ideas, tomorrow I'll switch it back to showing all the time so this doesn't become a big time sink.
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.
ui_framework/dist/ui_framework.css
Outdated
@@ -706,6 +706,7 @@ body { | |||
/* 2 */ | |||
font-size: 10px !important; | |||
/* 2 */ | |||
-webkit-transition: background-color 0.1s linear; |
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.
There's something funny going on where some people have been generating CSS that adds these properties, and yet I've been generating CSS that removes them. Are you using yarn to install your NPM deps by any chance? Which version of postcss do you have installed? I have 5.2.17.
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.
Not using yarn but I was on 5.2.11. I installed fresh, now I have 5.2.17 and I'm generating the same css as you (with the lines removed).
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.
😅 Thank you!
@cjcenizal @lukasolson alright, ready for another look.
|
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.
LGTM! Really nice improvement.
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.
LGTM!
Adds link to query syntax portion of query string query docs in the Kibana query bar.
Adds link to query syntax portion of query string query docs in the Kibana query bar.
Fixes #4250
Initially I was going to create a separate dropdown for this help text but integrating it with the typeahead felt like a more elegant solution. The help text will appear when the query bar is empty and has focus. When the user starts typing the help text will go away and the usual typeahead suggestions appear. For now the help text is static, but I think this paves the way for more dynamic help similar to Slack's search box.
The help content still needs some design polish, after which I'll also add it to the Visualize and Dashboard query bars.