From 4075140f65129bff3e584c2802976fd4955ac945 Mon Sep 17 00:00:00 2001 From: Marcin Rataj Date: Fri, 16 Oct 2020 21:49:04 +0200 Subject: [PATCH 1/3] feat: fast name search by default This changes the default behavior of the `name` filter from "case-insensitive, partial match" to "case-sensitive, exact (full) match" and adds `match` parameter that enables opt-in into `fuzzy` strategy only when performance is not an object. The rationale for this change that fuzzy search is a bad default, does not scale well and in most cases users and developers expect exact match. We are moving away from slow defaults in go-ipfs, and since `ipfs pin local` API will be inspired by this spec, we don't want to re-introduce bad choices into IPFS ecosystem. Developers who need fuzzy search, can always opt-in into slower, but more flexible text matching strategy by passing `match` parameter, but the default should be the fastest option available, and in this case it is the exact match. --- ipfs-pinning-service.yaml | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/ipfs-pinning-service.yaml b/ipfs-pinning-service.yaml index 0c175e3..0de9a22 100644 --- a/ipfs-pinning-service.yaml +++ b/ipfs-pinning-service.yaml @@ -202,6 +202,7 @@ paths: parameters: - $ref: '#/components/parameters/cid' - $ref: '#/components/parameters/name' + - $ref: '#/components/parameters/match' - $ref: '#/components/parameters/status' - $ref: '#/components/parameters/before' - $ref: '#/components/parameters/after' @@ -406,7 +407,7 @@ components: description: Optional name for pinned data; can be used for lookups later type: string maxLength: 255 - example: "my precious data" + example: "PreciousData.pdf" origins: $ref: '#/components/schemas/Origins' meta: @@ -461,6 +462,14 @@ components: example: status_details: "Queue position: 7 of 9" # PinStatus.info[status_details], when status=queued + TextMatchingStrategy: + description: Alternative text matching strategy + type: string + default: exact + enum: + - exact # full match, case-sensitive (the implicit default) + - fuzzy # partial match, case-insensitive + Failure: description: Response for a failed request type: object @@ -532,14 +541,23 @@ components: example: ["Qm1","Qm2","bafy3"] name: - description: Return pin objects with names that contain provided value (case-insensitive, partial or full match) + description: Return pin objects with specified name (by default a case-sensitive, exact match) name: name in: query required: false schema: type: string maxLength: 255 - example: "my precious" + example: "PreciousData.pdf" + + match: + description: Customize the text matching strategy applied when name filter is present + name: match + in: query + required: false + schema: + $ref: '#/components/schemas/TextMatchingStrategy' + example: exact status: description: Return pin objects for pins with the specified status From 91299ccbdba9b1a6808d58ab828ecc2772b9efdf Mon Sep 17 00:00:00 2001 From: Marcin Rataj Date: Tue, 20 Oct 2020 03:04:19 +0200 Subject: [PATCH 2/3] =?UTF-8?q?style:=20fuzzy=20=E2=86=92=20partial?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit https://github.com/ipfs/pinning-services-api-spec/pull/66#discussion_r506739796 https://github.com/ipfs/pinning-services-api-spec/pull/66#discussion_r507651040 --- ipfs-pinning-service.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ipfs-pinning-service.yaml b/ipfs-pinning-service.yaml index 0de9a22..4202c78 100644 --- a/ipfs-pinning-service.yaml +++ b/ipfs-pinning-service.yaml @@ -468,7 +468,7 @@ components: default: exact enum: - exact # full match, case-sensitive (the implicit default) - - fuzzy # partial match, case-insensitive + - partial # partial match, case-insensitive Failure: description: Response for a failed request From f96383a5857fa37aaa46943726b36b4263edf1eb Mon Sep 17 00:00:00 2001 From: Marcin Rataj Date: Tue, 20 Oct 2020 03:47:31 +0200 Subject: [PATCH 3/3] style: match=exact|iexact|partial|ipartial --- ipfs-pinning-service.yaml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/ipfs-pinning-service.yaml b/ipfs-pinning-service.yaml index 4202c78..5a51ba1 100644 --- a/ipfs-pinning-service.yaml +++ b/ipfs-pinning-service.yaml @@ -467,8 +467,10 @@ components: type: string default: exact enum: - - exact # full match, case-sensitive (the implicit default) - - partial # partial match, case-insensitive + - exact # full match, case-sensitive (the implicit default) + - iexact # full match, case-insensitive + - partial # partial match, case-sensitive + - ipartial # partial match, case-insensitive Failure: description: Response for a failed request