-
Notifications
You must be signed in to change notification settings - Fork 16
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 keyword search to filter example queries #83
Add keyword search to filter example queries #83
Conversation
Maybe debouncing the search would be nice |
@IoannisNezis This is awesome! It's live on https://qlever.cs.uni-freiburg.de for some time now and I use it for almost every example query. The underlining looks great. A minor suggestion for further improvement: When one clicks on the |
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.
Looks great, a few minor suggestions. Using match(regex)
for the search is not a must, but maybe you like it.
backend/static/js/keywordSearch.js
Outdated
@@ -0,0 +1,76 @@ | |||
// this function removes the highlight |
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.
A minor comment: Our comment style is normal sentences (capitalized and with a full stop). I know that a lot of the qlever-ui does not follow this rule yet. That's becase it's old. But nor reason not to stick to this for all new code.
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.
Ah, good to know!
I generated some docstrings with chatGPT.
Do the new comments satisfy the comment style?
/**
* Removes highlighting from the input string by replacing all occurrences of
* <span> elements with the class "keyword-search-highlight" with their inner content.
*
* @param {string} input_str - The input string possibly containing highlighted spans.
* @returns {string} - The input string with highlighting 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.
We use ordinary // ...
comments with full sentences. When referring to variable or class names in a comment, we put it in ...
. See the code on https://github.com/ad-freiburg/qlever for many examples of this (it's also not 100% consistent there, but 90% of the comments follow this convention).
@IoannisNezis This looks great now. Another small request, which occurred to me already when trying this out the first time and still occurs to me now every time I used the new feature: When selecting a query using the "Example" button one has to:
For Step 4, there is the Shortut Ctrl+Return, which I always use to execute a query (after you type the query, you can just continue typing in instead of having to switch to the mouse again just for a single click). But with the workflow above, I have to click, type, click, click It would be awesome if one could select the query with either TAB or arrow-up / arrow down and then select it via Return (and another Ctrl+Return would then execute it). Interestingly, when pressing TAB once, one already gets to "Add new example", and then Return takes you to the corresponding page. So maybe realizing this with TAB is relatively little additional work. |
@hannahbast At this point it might be worth mentioning that i am re-implementing parts of this library: https://select2.org/ which i initially choose not to use. If there is a good reason not to use this library i would be really happy (sunken cost fallacy is kicking in really badly). |
I implemented the keyboard control. I decided against the tabulator option and implemented the selection with arrow keys. Further improvementsI want to implement 2 further improvements: ScrollThe list of possible examples is a bit long. Exclusive HoverCurrently one can select a example with the mouse and the arrow keys. |
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.
1-1 with Ioannis, this looks great, just some minor changes
@hannahbast A few things:
|
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.
Finally finishing this review and merging this. Thanks for the extremely useful addition, Ioannis!
* master: Don't ignore `db` when building Docker image (ad-freiburg#101) Update deprecated setting for static storage (ad-freiburg#95) Build and push Docker image after each commit to the master (ad-freiburg#98) Update db/qleverui.sqlite3 to latest configs and example queries Display details for operation in "Analysis" tree as tooltip (ad-freiburg#80) Bump dependencies `requests`, `gunicorn`, `django` to latest version Improvements in Docker setup (ad-freiburg#90) Add keyword search to filter example queries (ad-freiburg#83) Restore default qleverui.sqlite3 Fix regex in replacePredicatesList No subject AC query for short prefix
This PR adds a keyword-search to filter the example querys (by name).
Each whitespace sperated word needs to appear in the result.
The search matches the keyword also
infix
When no result matches the query, a message is displayed.