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

Ability to search by using logical OR connective #23

Closed
gamtiq opened this issue Mar 16, 2014 · 13 comments
Closed

Ability to search by using logical OR connective #23

gamtiq opened this issue Mar 16, 2014 · 13 comments

Comments

@gamtiq
Copy link

gamtiq commented Mar 16, 2014

As I understand, currently AND connective/operator is used when search is made with two or more parameters.
Is it possible to add support for OR connective someway?
So that for example search for name=*key*&description=*key* would return list with packages whose name or description contains specified key.

@bebraw
Copy link
Contributor

bebraw commented Mar 16, 2014

It's AND, yes. Does it make sense to support OR on API level? What if you just performed multiple queried and then combined the results?

@gamtiq
Copy link
Author

gamtiq commented Mar 16, 2014

I suppose that support for OR is not absolutely necessary. But it is convenient in some situations.
To make multiple queries and to combine results is a possible approach. But it leads to extra request(s) which may cause growth of burden for network and server.

@bebraw
Copy link
Contributor

bebraw commented Mar 16, 2014

Ok. Can you propose an approach? What it would look like on API level?

@gamtiq
Copy link
Author

gamtiq commented Mar 16, 2014

One way is to make it by using some special parameter. Maybe it is not the best way but at least it should be quite simple and understandable (I hope).

@tomByrer
Copy link
Contributor

What it would look like on API level?

http://api.jsdelivr.com/v2/jsdelivr/libraries?or(name=*jquery*+description=*jquery*+mainfile=*jquery*)&not(name=jquery)
Should find all repos that use jQuery, but is not the jQuery distro itself.

Could use , as a deliminator instead of + (my preference is , but I used the jsDelivr multifile API. Perhaps always use wildcard search for long fields like description? Also, prose fields like URLs & description need to be lowercased.
Sound good?

@tomByrer
Copy link
Contributor

oops, had to fix my API example

@gamtiq
Copy link
Author

gamtiq commented Mar 16, 2014

I like this proposal.
Maybe , as a separator is more readable.

@bebraw
Copy link
Contributor

bebraw commented Mar 16, 2014

http://api.jsdelivr.com/v2/jsdelivr/libraries?or(name=*jquery*+description=*jquery*+mainfile=*jquery*)&not(name=jquery)
Should find all repos that use jQuery, but is not the jQuery distro itself.

Why would you want to exclude jQuery distro?

If we want to get away with the least effort, we can do just op=or to override default. Less API to remember and easier to implement but that won't be as powerful as what you are suggesting. This would look something like this:

http://api.jsdelivr.com/v2/jsdelivr/libraries?op=or&name=*jquery*&description=*jquery*&mainfile=*jquery*

In addition you would filter out jquery library itself on client side to match your use case. This seems like a special case to me and I'm not entirely convinced yet it would be a good idea to provide it on the API level. A lot added of complexity for little benefit.

@gamtiq
Copy link
Author

gamtiq commented Mar 16, 2014

I agree with op=or approach if it can be implemented without considerable efforts.

@bebraw
Copy link
Contributor

bebraw commented Mar 16, 2014

@gamtiq It's a very small change. Given it's backwards compatible I can add it to v1 API even.

@tomByrer What do you think?

@tomByrer
Copy link
Contributor

Honestly, I find the op=or harder to read; does op=or&name=*jquery*&description=*jquery*&mainfile=*jquery* mean

SELECT *
FROM libraries
WHERE name LIKE '%jquery%' OR description LIKE '%jquery%' AND mainfile LIKE '%jquery%'

or

SELECT name, description, mainfile
FROM libraries
WHERE (name LIKE '%jquery%' AND description LIKE '%jquery%') OR (name LIKE '%jquery%'  AND mainfile LIKE '%jquery%'

?
If parens are added to op=or then that will be easier to read by eyes, but if that is slower in server &/or client, then please do what is most efficient. Either way, thanks for asking for feedback!

NOT seems like a special case

If too much work, don't bother please :)

@bebraw
Copy link
Contributor

bebraw commented Mar 17, 2014

op=or changes default behavior to OR so instead of having AND for all you get OR. So in case any of the query parameters matches, it will be returned.

It would be a very easy change to make. Just wondering if it would be useful.

@gamtiq Would that help in your use case?

@gamtiq
Copy link
Author

gamtiq commented Mar 17, 2014

I suppose that would be enough and quite useful.

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

No branches or pull requests

3 participants