-
Notifications
You must be signed in to change notification settings - Fork 0
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
Searching and Filtering in the API #11
Comments
Edit: After some thought and some discussion with @kenowi-dev I have updated this comment to an actual proposal. What feature do you want to propose?This is a proposal for an API for searching songs. While this proposal is only concerned with searching songs, the API is easily extensible to other searches as well. The API takes heavy inspiration from the syntax used by the GitHub Issue Search. Why does Karman need this feature?Searching is one of the core features for any library management application. Obviously this is not the most Simple API for this purpose. There are however some major advantages to a design like this (see Alternatives Considered), especially when it comes to usability and extensibility. How do users access the feature?In the first instance this is an API feature. It would be accessed via endpoints that list songs such as ˋ /v1/songsˋ or ˋ/v1/uploads/{uuid}/songsˋ. From the external perspective the feature is available via a GET parameter (ˋqueryˋ) in which a search query in a custom format is passed. The format is described below. This search query format might be passed on to the UI to allow users to craft their own searches. This is not part of this proposal. Describe alternatives you've considered
Additional contextThe following paragraphs describe the format of a query. A query is divided into space-separated fields. Each of these fields can have one of two formats:
If any value contains spaces the quoted format must be used. All values are case insensitive. Each field corresponds to a search/filter clause, all of which are ANDed:
As an example consider the search query
Implementation ConsiderationsOn the backend I imagine the implementation pretty straightforward: Every clause basically results in an additional A potential parser for this kind of search format should probably be pretty lenient. Instead of raising errors when the query is not correctly formatted we could probably achieve a better experience by just returning an empty result or by ignoring parts of the query. |
I would suggest that we will have a parameter for each attribute. Furthermore I would have multiple parameters for each attribute (I saw a page with an idea i really liked): You could search in different ways: "contains", "does not contain", "begins with", "ends with", "equals", "does not equal". For numbers: "greater than", "lower than". And i really liked that idea. In the UI you could nicely implement this by having a dropdown next to the search input. The GET Parameter could look something like this:
title_contains=someTitle
ortitle_beginswith=something
@codello says: I do not currently have a good concept of how to implement searching on an API level. I almost feel like we would need some kind of (custom) querying language to accommodate all cases for searching. Maybe we should move this to it's own issue to develop a good idea of what criteria should be searchable by what operations.
The text was updated successfully, but these errors were encountered: