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

Improve search form autocompletion #341

Merged
merged 56 commits into from
Apr 12, 2024
Merged

Improve search form autocompletion #341

merged 56 commits into from
Apr 12, 2024

Conversation

dabico
Copy link
Member

@dabico dabico commented Apr 12, 2024

What initially started as a simple library replacement quickly ballooned into a massive refactoring. In essence, endpoints that expose information regarding:

  • label
  • topic
  • license
  • language

Can now be fully searched. The server endpoints are programmed in such a way that they return pages of matches in the following order:

  • Exact matches;
  • Partial matches that start with the provided string;
  • Partial matches that contain the provided string in the middle;
  • Partial matches that end with the provided string.

Within each match group results are further sorted according to their prevalence across projects. Items with comparable popularity are finally sorted alphabetically. On the other hand, if no search string is provided the endpoints will return the most popular terms. This allowed us to change the search form autocomplete suggestions: The user clicks on the input and receives an initial set of suggestions according to the most popular items. They then type out what they want to search for, receiving suggestions following a quarter-second debounce. At the same time, a loading spinner is rendered to indicate that the items are being fetched. Once the server response is received, the spinner is hidden revealing a list of the 10 top-most matching results. Each result also contains a highlighted portion of text, indicating why this result is included. The user can then click or keyboard-navigate and select one of the options, setting the value of the search form field.

First in a series of commits centered on replacing the `typeahead`
library with the `autocomplete`. The latter provides more
functionalities while being visually equivalent to the former.
`getRanked` has been replaced by `getAll`
Now provides the ability to retrieve labels whose name matches a
certain pattern, as well as the previous retrieval of most popular.
Metamodel classes are not generated for inner-class entities.
In the meantime, we work around this by manually writing the
definitions. Although this completely mitigates any advantages
that the automatic generation provides, I refuse to separate so
many things into their own micro-classes.
The script started out just for "language", but will further evolve for
all autocompletion configuration.
This is so that they are consistent in name with the other views.
Creating a materialized view here is unnecessary in my opinion,
since the queried column is indexed. If we were to materialize,
then more new triggers would need to be created.
The view will not be enough unfortunately, the join performance seems
to be quite poor without a foreign key. For this reason I changed
`license_statistics` from a view to a regular table, akin to the `label`
and `topic` counterparts.
The reason this "does not work" before was because Spring Data JPA can
not infer the count queries for these. Once I wrote them myself it was
business as usual.
@dabico dabico changed the title Enhance Improve search form autocompletion Apr 12, 2024
@dabico dabico merged commit 6b59c52 into master Apr 12, 2024
8 checks passed
@dabico dabico deleted the enhancement/autocomplete branch April 12, 2024 22:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant