mitodl / ocw-hugo-themes

A Hugo theme for building OCW websites
BSD 3-Clause "New" or "Revised" License
5 stars 4 forks source link

Update the ocw search page to use the new search apis #1294

Closed abeglova closed 9 months ago

abeglova commented 10 months ago

We changed the search apis on open to accept filter parameters instead of an open search query. This will be the api we will be using going forward. For now OCW is using the legacy search api that is separately running on open-discussions. We want to update ocw to use the new apis so we no longer need to support the legacy search.

The bulk of the updates will happen in course-search-utils. Currently course-search-utils

1) Keeps track of search facet state 2) Keeps the parameters in the url of the search page in sync with the facet state 3) Generates the open search query

Now that we are moving to a new api we can get rid of (3) but (1) and (2) is still code that we want to share among all uis that use the search.

The work that needs to be done is

In course-search-utils: 1) Get rid of the large amount of code that generates the open search query and replace it with a small function that formats the active facets into get parameters 2) Rename the available facets to match the new parameters used by the api. For example the facet formerly known as type is now resource_type and the facet formerly called 'resource_typeiscontent_feature_type`

In ocw-hugo-themes: 1) Update the code that displays facets to use use the new facet names 2) Update the code that converts search results to a LearningResource object that can be used by course cards to use the new search result format 3) Update the code that actually makes the api call to make a get to the new endpoint instead of a post to the old endpoint

To make sure that everything works together the course-search-utils and ocw-hugo-themes work should happen silmultaneously

abeglova commented 10 months ago

One issue with this plan is that the reddit part of open-discussions has a search feature which uses course-search-utils and will be pinned to an old release of course-search-utils. I think this is ok. We don't have plans for further development for discussions and if we ever need to make changes to the query generating code (because of a breaking change in open search, say) we can fork course-search-utils.

abeglova commented 10 months ago

Alternatively we can fork course-search-utils now, but I'm hoping we won't need to do more development on the channel/discussion search so we can hold off

ChristopherChudzicki commented 10 months ago

One issue with this plan is that the reddit part of open-discussions has a search feature which uses course-search-utils and will be pinned to an old release of course-search-utils. I think this is ok. We don't have plans for further development for discussions and if we ever need to make changes to the query generating code (because of a breaking change in open search, say) we can fork course-search-utils.

Alternatively we can fork course-search-utils now, but I'm hoping we won't need to do more development on the channel/discussion search so we can hold off

If we release the new version as 3.x, we should be fine. Renovate in open-discussions repository shouldn't bump a major version. And if we ever needed to fix something critical in the old 2.x branch, we could.


I'm going to take a closer look at course-search-utils. There are a few things I think we should consider improving.