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

Add search functionality #189

Merged
merged 5 commits into from
Apr 18, 2023
Merged

Add search functionality #189

merged 5 commits into from
Apr 18, 2023

Conversation

jp7677
Copy link
Contributor

@jp7677 jp7677 commented Mar 28, 2023

Still work-in-progress, but works already.

@qtzar
Copy link
Contributor

qtzar commented Mar 28, 2023

Pulled a clone of this and it is a nice addition.

I do wonder if it would be better to add the search box to the top menu bar instead of it being a page of its own in the side nav. That way it can be accessed from anywhere instead of having to go to the search page first.

@jp7677
Copy link
Contributor Author

jp7677 commented Mar 29, 2023

Things to consider/discuss before moving on:

  • Note that this is not a server side search, but a client (browser) side search. I guess this wont perform anymore for sites with thousands of ADR/Sections. May be we need an opt-in or opt-out switch for those cases?
  • This PR introduces Lunrjs (https://lunrjs.com/ / https://github.com/olivernn/lunr.js ). This package works perfectly here and offers a nice set of features (scoring / search syntax), but development has been silent since 2020. The maintainer has no recent GitHub activity. So not sure if this is a perfect choice?
  • The UI is up for discussion. The presentation of the result list is far from beautiful (I'm really no designer) and having (also?) a search field in the header would indeed be nice (doable by passing the search terms by query parameter to the search page). Suggestions for a better presentation of the search results are very welcome.
  • Generating the to be indexed documents is currently fine-grained for certain parts of the C4 model. This needs to be extended to also index relations, containers etc. That said, another approach would be to simply look at the generated html files and take the to be indexed text from there. This "brute-force" approach would catch all text (likely to much like table headings) and requires nearly no maintenance for future changes, but we might index things we don't want to index. I'm not sure yet what the better approach is. After playing further with it, the fine-grained approach is definitively better.

~(Obviously unit tests are currently not complete) ~

Any thoughts?

@qtzar
Copy link
Contributor

qtzar commented Mar 30, 2023

A possible alternative to lunr could be fuse.js

A quick look at npmtrends shows that it is the most active of any of the lightweight js search engines.
( https://npmtrends.com/fuse.js-vs-lunr)

@jp7677 jp7677 force-pushed the search branch 3 times, most recently from d5e995a to 6d675f8 Compare April 5, 2023 15:35
@jp7677 jp7677 force-pushed the search branch 8 times, most recently from d5ef5c6 to 77cac60 Compare April 7, 2023 10:11
This is based on Lunrjs.
We assemble documents when generating the site, then Lunr builds
an index on the client on page load and we search through that.
@jp7677 jp7677 marked this pull request as ready for review April 11, 2023 07:43
@jp7677 jp7677 changed the title Add search page Add search functionality Apr 11, 2023
@jp7677
Copy link
Contributor Author

jp7677 commented Apr 11, 2023

@dirkgroot I'm pretty happy now how it works (and looks). Feel free to give it a try. I'm looking forward to your impressions and feedback.

@dirkgroot
Copy link
Collaborator

@dirkgroot I'm pretty happy now how it works (and looks). Feel free to give it a try. I'm looking forward to your impressions and feedback.

I like it. It looks nice, and I it's very useful.

I do, however, think that with changes like this, we need to be wary of getting to a point where the code required for the "richer" user experience is getting too hard to maintain.

This tool was never designed with a "rich" user experience in mind, so any JavaScript code added to this will never be a "first class citizen". Nothing is set up for unit testing, or keeping dependencies up-to-date. Adding more stuff like this, will increase the risk of things breaking when changes are made. This is part of the reason why I'm not really keen on merging #180.

However, functionality-wise, I do think that this is a really useful addition.

@jp7677
Copy link
Contributor Author

jp7677 commented Apr 12, 2023

I do, however, think that with changes like this, we need to be wary of getting to a point where the code required for the "richer" user experience is getting too hard to maintain.

This tool was never designed with a "rich" user experience in mind, so any JavaScript code added to this will never be a "first class citizen". Nothing is set up for unit testing, or keeping dependencies up-to-date. Adding more stuff like this, will increase the risk of things breaking when changes are made. This is part of the reason why I'm not really keen on merging #180.

yeah, I'm seeing this too. As discussed a while ago, for the long term some real end-to-end tests are needed to mitigate the risks you've mentioned and we should think about how renovate can catch up on client package updates.

@dirkgroot dirkgroot merged commit 92766a4 into avisi-cloud:main Apr 18, 2023
@jp7677 jp7677 deleted the search branch April 18, 2023 13:52
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.

3 participants