Giter Site home page Giter Site logo

Comments (13)

bebraw avatar bebraw commented on May 23, 2024

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?

from api.

gamtiq avatar gamtiq commented on May 23, 2024

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.

from api.

bebraw avatar bebraw commented on May 23, 2024

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

from api.

gamtiq avatar gamtiq commented on May 23, 2024

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).

from api.

tomByrer avatar tomByrer commented on May 23, 2024

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?

from api.

tomByrer avatar tomByrer commented on May 23, 2024

oops, had to fix my API example

from api.

gamtiq avatar gamtiq commented on May 23, 2024

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

from api.

bebraw avatar bebraw commented on May 23, 2024

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.

from api.

gamtiq avatar gamtiq commented on May 23, 2024

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

from api.

bebraw avatar bebraw commented on May 23, 2024

@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?

from api.

tomByrer avatar tomByrer commented on May 23, 2024

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 :)

from api.

bebraw avatar bebraw commented on May 23, 2024

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?

from api.

gamtiq avatar gamtiq commented on May 23, 2024

I suppose that would be enough and quite useful.

from api.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.