ipfs / pinning-services-api-spec

Standalone, vendor-agnostic Pinning Service API for IPFS ecosystem
https://ipfs.github.io/pinning-services-api-spec/
Creative Commons Zero v1.0 Universal
99 stars 26 forks source link

feat: fast exact name search by default #66

Closed lidel closed 3 years ago

lidel commented 3 years ago

tldr

This PR changes the default behavior of the name filter

from case-insensitive, partial match to much faster case-sensitive, exact (full) match

and adds match parameter that enables opt-in into alternative strategy when performance is not an object:

Screenshot_2020-10-26 IPFS Pinning Service API

PREVIEW: https://ipfs.github.io/pinning-services-api-spec/#specUrl=https://raw.githubusercontent.com/ipfs/pinning-services-api-spec/fix/default-to-fast-name-match/ipfs-pinning-service.yaml

Rationale for this change

Implementation notes and migration plan


@aschmahmann @jacobheun @petar @gammazero @obo20 @andrew @GregTheGreek @priom @jsign @sanderpick @andrewxhill @ipfs/wg-pinning-services

achingbrain commented 3 years ago

Do we need a match parameter at all? Can we not just look at the passed name and if it contains a * character it's a wildcard match and if not it's exact? Case sensitive/insensitive or search flags could be an option?

lidel commented 3 years ago

@achingbrain If we replace match with support for * and add optional case=sensitive|insensitive, then services need to implement parser and 4 strategies instead of two (exact-casesensitive, exact-caseinsensitive, partial-casesensitive, partial-caseinsensitive), and API users need to learn that * has special meaning, and we need to spec that it can't be used in names (or spec how to escape it).

I'd argue match=exact|iexact|partial|ipartial added in f96383a is much easier for services and users, but I'm open for suggestions if there is a simpler way to represent this (when match is missing, exact is used).

andrew commented 3 years ago

PR for implementation on the ruby pinning api server over here: https://github.com/ipfs-shipyard/rb-pinning-service-api/pull/5

obo20 commented 3 years ago

This PR looks great to me. The changes will be helpful in keeping things performant by default while also allowing for some flexibility.