mitodl / mit-learn

BSD 3-Clause "New" or "Revised" License
0 stars 2 forks source link

Fix messy urls multiword api filters #148

Closed abeglova closed 2 months ago

abeglova commented 1 year ago

Currently the urls for multiword searches are messy. For example http://localhost:8063/api/v1/learning_resources_search/?department=Global%20Studies%20and%20Languages.

One solution is to ignore whitespace (we are already ignoring case) in filters using an analyzer https://opensearch.org/docs/latest/analyzers/search-analyzers/ so that search could be http://localhost:8063/api/v1/learning_resources_search/?department=globalstudiesandlanguages.

ChristopherChudzicki commented 1 year ago

I think this is motivated by @Ferdi 's comment:

Can we use some key, like sse or sloan-exectutive-education in stead of 'sloan executive education'. It would be easier for the clients . I would say the same thing for topics and departments. E.g. this is not a friendly url

Suggestion: When it comes to making nice-looking URLs out of things with spaces, we should just encode spaces as + not %20. They are equivalent in the query parameter portion of URLs (and only in that portion). For example, this is how google encodes searches with spaces. https://www.google.com/search?q=cats+and+dogs

This will also work for the search text, where we probably don't want to ignore whitespace.

On the other hand: If we want to encode departments, etc, for some reason other than URL prettyness, then using a key or dashes makes sense. Or if we want really short URLs, then "sse" for "sloan executive education" makes sense.

abeglova commented 1 year ago

Good point! In that case we might not need to do anything. http://localhost:8063/api/v1/learning_resources_search/?department=Women%27s+and+Gender+Studies. Works just fine as a filter.

@Ferdi Do we want to display see instead of "sloan executive education" in the search results or just the filter? And if we want see and not "sloan executive education" as the filter, but not in the data returned from the api does the fact that the url can be offered_by=sloan+executive+education make a difference?

Ferdi commented 1 year ago

btw, is this issue https://github.com/mitodl/mit-open/issues/149 the same as this one ?

abeglova commented 1 year ago

No, this issue is about how we want to display urls https://github.com/mitodl/mit-open/issues/149 is about how we want to display the resource type in results and filters

sovsey commented 2 months ago

This has been addressed (e.g. https://mitopen-rc.odl.mit.edu/search/?q=molecular+biology)