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 basic search filters (experimental) #1080

Merged
merged 7 commits into from
Mar 12, 2024

Conversation

owi92
Copy link
Member

@owi92 owi92 commented Jan 16, 2024

This adds a first iteration of basic filters for item type ("all", "videos", "pages") and time frame.
There are some open questions regarding how to deal with pages while the time filter is active, since pages do not have a timestamp. This means they are not affected by the filter.

Lukas and I decided to split to reworking of the search into multiple PRs with incremental improvements and features added. This is now only laying the foundation for these work packages, and will not change anything visible for now.
Filters are included but hidden behind the tobiraExperimentalFeatures flag (this is mainly information for developers).

Part of #1063

@github-actions github-actions bot added the status:conflicts This PR has conflicts that need to be resolved label Jan 16, 2024

This comment was marked as resolved.

@owi92 owi92 added area:search Related to Tobira's search changelog:user User facing changes area:usability Usability related issues labels Jan 16, 2024
@github-actions github-actions bot removed the status:conflicts This PR has conflicts that need to be resolved label Jan 16, 2024
@github-actions github-actions bot temporarily deployed to test-deployment-pr1080 January 16, 2024 12:28 Destroyed
@github-actions github-actions bot temporarily deployed to test-deployment-pr1080 January 16, 2024 13:52 Destroyed
Copy link
Member

@LukasKalbertodt LukasKalbertodt left a comment

Choose a reason for hiding this comment

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

Thanks for adding filters!

I only tested this, without having looked at the code much. I have a few design suggestions below. But unfortunately, one big thing still needs to change: the filtering needs to happen in the backend, not the frontend.

Filtering in the frontend means that the "hits" count is wrong. But more importantly, it can break in other ways. The backend currently returns a fixed number of results. If you filter by date, and it happens that none of the returned results lie in the date range, but some events (that were not returned by the endpoint) would be in the date range, then that's bad. It also doesn't work well with pagination/infinite scrolling.

So yes, the API needs to be extended to allow specifying the filter parameter. And then the backend need to pass the filter settings to Meili so that Meili performs the actual filter. Filtering the kind of item (video, page, ...) can be done in our backend because we send one Meili request per kind. So we can just not send the ones that are not requested. That surely requires a small bit of refactoring but should work.

Now onto my other suggestions:

  • I would probably suggest adding all filter settings as URL parameters. Otherwise if you would click an item, and then navigate back, all your filter settings are gone.
  • I would separate the different kinds of filters into different sections, so that the date filter is not in the same line as the kind filters.
  • I would add a heading (at least visually, don't know if it needs to be <hX> to the whole filter section ("Filter") and also to each subsection. See the sketch below.
  • On narrow screens, when the filter is above the results, we probably need to make it collapsible, especially as we add more filter options. But doesn't necessarily need to happen now.
  • I find the "kind" filter buttons quite large. They are our normal buttons, but I would rather go with a smaller "label-ly" style. Also see sketch.
  • For UX it would be nice to have a few quick buttons for date ranges ("last week", ...).
  • The button to select the time frame could use a tooltip. Or... thinking about it, in my design it would even fit well to show the actual date range without hiding it in a button. Then you can see at a glance what the current filter is.

So yeah here is some rough sketch. It would need more polish for sure, but sth like that I had in mind. Let me know what you think, this is just a suggestion, so we can arrive at a good result together.

image

@oas777
Copy link
Collaborator

oas777 commented Jan 17, 2024

Thanks, Ole. Some unsorted comments from the user perspective:

  • I still fail to see the relevance of searching for "Pages" in a video portal.
  • The current design doesn't convey a filter feature. Active filters at least have to show how many results were filtered.
  • The date picker is the last thing we want when filtering temporally. Instead, we have to filter
  1. by semester (if applicable)
  2. by year,
  3. then we can use the quick buttons. And for the desperate user,
  4. there's the date picker at the end of the line.

@oas777
Copy link
Collaborator

oas777 commented Jan 17, 2024

PS: "Pages" are also difficult to combine with future "source filters" (metadata/slides/transcripts).

@owi92
Copy link
Member Author

owi92 commented Jan 17, 2024

Thank you for your feedback. Both of you make valid points, so I will crawl back into my cave and come up with something nicer to accomodate your suggestions.

Regarding the relevance of searching pages, I definitely agree that it makes filtering unreasonably complicated.
I can however imagine the use case of wanting to look for specific pages as long as these are used for something like collections. That might be redundant once we have playlists, but I doubt it will become completely useless.

@LukasKalbertodt
Copy link
Member

  • I still fail to see the relevance of searching for "Pages" in a video portal.

I also think this can be useful. Most of the time the page will list exactly one series which, in the future, means we will only show that series in the results. And I think we all agree that series should appear in the search results right?

Active filters at least have to show how many results were filtered.

That's technically very hard to do. At least in the general case. I just took a look at your old video portal. And that would indeed be possible: sort each of the results in one of a fixed number of buckets, and show how many are in each bucket. But with some filters we want to add, this model does not apply.

The date picker is the last thing we want when filtering temporally. [..]

Mh that is a good point. I also checked your old video portal regarding that. And I agree that from a UX perspective this is good. But... this is not trivial to do, especially not in a way that works for everyone (semesters are different for every university after all). We will come up with an implementation plan internally.

PS: "Pages" are also difficult to combine with future "source filters" (metadata/slides/transcripts).

So are "series" and as mentioned above, I think it's clear we want to be able to find those. So yes, with that difficulity we have to deal.

@oas777
Copy link
Collaborator

oas777 commented Jan 17, 2024

And I think we all agree that series should appear in the search results right?

Nope. If it makes things easier with respect to some other features mentioned here, I'm not that keen.

@dagraf
Copy link
Collaborator

dagraf commented Jan 17, 2024

And I think we all agree that series should appear in the search results right?

Yes. I would appreciate series appearing in the search results and some day adding a filter for series (and maybe also playlists).

@owi92 owi92 marked this pull request as draft January 22, 2024 10:03
@owi92 owi92 changed the title Add rudimentary search filters Add rudimentary search filters (experimental) Feb 22, 2024
@owi92 owi92 marked this pull request as ready for review February 22, 2024 16:27
@github-actions github-actions bot temporarily deployed to test-deployment-pr1080 February 22, 2024 16:32 Destroyed
@github-actions github-actions bot temporarily deployed to test-deployment-pr1080 February 22, 2024 16:39 Destroyed
@github-actions github-actions bot temporarily deployed to test-deployment-pr1080 February 23, 2024 15:52 Destroyed
Copy link
Member

@LukasKalbertodt LukasKalbertodt left a comment

Choose a reason for hiding this comment

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

I didn't have a close look on all frontend components, but all of this looks like a good approach. No rework necessary. I will have to do a closer frontend review later, but I left a few comments already that should be fixed.

For the bystanders Olaf and David: we decided to make this PR just about code architecture stuff. Merging it will not actually result in any user-visible change. Before we do that we will reconsider the search page design a bit, including filters. And show you ideas before implementing it. So for now you can probably ignore this pull request.

backend/src/api/model/search/mod.rs Outdated Show resolved Hide resolved
backend/src/api/model/search/mod.rs Outdated Show resolved Hide resolved
backend/src/api/model/search/mod.rs Outdated Show resolved Hide resolved
backend/src/api/model/search/mod.rs Outdated Show resolved Hide resolved
// We can either use score details or adding dummy searchable fields to the
// realm index. See this discussion for more info:
// https://github.com/orgs/meilisearch/discussions/489#discussioncomment-6160361
let events = event_results.hits.into_iter()
.map(|result| (NodeValue::from(result.result), result.ranking_score));
let realms = realm_results.hits.into_iter()
.map(|result| (NodeValue::from(result.result), result.ranking_score));
let mut merged = realms.chain(events).collect::<Vec<_>>();
let mut merged: Vec<(NodeValue, Option<f64>)> = Vec::new();
// Probably also not the best way of doing this.
Copy link
Member

Choose a reason for hiding this comment

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

Yeah so again, if the user specified only searching for events, we shouldn't send a realm search request to Meili and just ignore the results. I realize that this might be harder to implement though, but yeah it would be nice to just send the search requests that are necessary. And while you're refactoring that anyway, keep in mind that series and playlists might be added in the future, so maybe opt for a design that can be easily extended.

frontend/src/routes/Search.tsx Outdated Show resolved Hide resolved
frontend/src/routes/Search.tsx Outdated Show resolved Hide resolved
frontend/src/routes/Search.tsx Outdated Show resolved Hide resolved
frontend/src/routes/Search.tsx Outdated Show resolved Hide resolved
frontend/src/routes/Search.tsx Outdated Show resolved Hide resolved
@github-actions github-actions bot temporarily deployed to test-deployment-pr1080 February 28, 2024 12:32 Destroyed
backend/src/api/model/search/mod.rs Outdated Show resolved Hide resolved
backend/src/api/model/search/mod.rs Outdated Show resolved Hide resolved
backend/src/api/model/search/mod.rs Outdated Show resolved Hide resolved
backend/src/api/query.rs Outdated Show resolved Hide resolved
frontend/src/routes/Search.tsx Outdated Show resolved Hide resolved
frontend/src/routes/Search.tsx Outdated Show resolved Hide resolved
@github-actions github-actions bot temporarily deployed to test-deployment-pr1080 February 29, 2024 22:14 Destroyed
@github-actions github-actions bot temporarily deployed to test-deployment-pr1080 March 5, 2024 10:30 Destroyed
@github-actions github-actions bot temporarily deployed to test-deployment-pr1080 March 5, 2024 10:40 Destroyed
@github-actions github-actions bot temporarily deployed to test-deployment-pr1080 March 5, 2024 10:56 Destroyed
frontend/src/layout/header/Search.tsx Outdated Show resolved Hide resolved
frontend/src/routes/Search.tsx Outdated Show resolved Hide resolved
frontend/src/routes/Search.tsx Outdated Show resolved Hide resolved
frontend/src/routes/Search.tsx Outdated Show resolved Hide resolved
frontend/src/routes/Search.tsx Show resolved Hide resolved
@owi92 owi92 changed the title Add rudimentary search filters (experimental) Add basic search filters (experimental) Mar 7, 2024
@github-actions github-actions bot temporarily deployed to test-deployment-pr1080 March 7, 2024 11:11 Destroyed
@github-actions github-actions bot temporarily deployed to test-deployment-pr1080 March 7, 2024 11:19 Destroyed
This adds a slight delay before starting the search
while typing.
This adds filters to show either videos or pages
exclusively. When we add more item types in the future,
we might want to consider to allow to combine filters,
i.e. showing both series and videos but not pages, or any
other combination.
While there are nice libraries for this, they are
either quite large, unmaintained or don't work out
of the box, so I built a simple component for this
myself, though that is neither super fancy nor pretty.
For now, the filters are hidden behind the `experimentalFeatures`
flag. They are to be extended and or redone in the future, but
the aim of this commit is to lay the foundation for that.
Previously the numbers of total hits were bunched
together regardless of the selected filter. Now it
only shows the number of the filtered results.
@github-actions github-actions bot temporarily deployed to test-deployment-pr1080 March 7, 2024 11:23 Destroyed
This PR slightly changes the breadcrumb formatting,
so that needed to get adjusted accordingly in the
respective UI test.
@github-actions github-actions bot temporarily deployed to test-deployment-pr1080 March 7, 2024 11:38 Destroyed
Copy link
Member

@LukasKalbertodt LukasKalbertodt left a comment

Choose a reason for hiding this comment

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

👍

As discussed internally, we will wait with merging this until we published the next release. But yeah, this is good to go.

@LukasKalbertodt LukasKalbertodt merged commit fe112e6 into elan-ev:master Mar 12, 2024
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:search Related to Tobira's search area:usability Usability related issues changelog:user User facing changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants