From 687c4d5d243d1f1f6ec6f30df54b735733f9e932 Mon Sep 17 00:00:00 2001 From: Bart Koelman Date: Sat, 18 Sep 2021 09:05:19 +0200 Subject: [PATCH 1/2] Corrected example --- docs/usage/reading/filtering.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/usage/reading/filtering.md b/docs/usage/reading/filtering.md index 1d98bee35d..26b4220c65 100644 --- a/docs/usage/reading/filtering.md +++ b/docs/usage/reading/filtering.md @@ -63,7 +63,7 @@ Aside from filtering on the resource being requested (which would be blogs in /b filtering on included collections can be done using bracket notation: ```http -GET /articles?include=author,tags&filter=equals(author.lastName,'Smith')&filter[tags]=contains(label,'tech','design') HTTP/1.1 +GET /articles?include=author,tags&filter=equals(author.lastName,'Smith')&filter[tags]=any(label,'tech','design') HTTP/1.1 ``` In the above request, the first filter is applied on the collection of articles, while the second one is applied on the nested collection of tags. From a9ddeab14811b38b1bcde625e2ffcdf2d117e9c1 Mon Sep 17 00:00:00 2001 From: Bart Koelman Date: Sat, 18 Sep 2021 09:19:25 +0200 Subject: [PATCH 2/2] Added clarification on nested filter usage --- docs/usage/reading/filtering.md | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/docs/usage/reading/filtering.md b/docs/usage/reading/filtering.md index 26b4220c65..dab1fdb6e2 100644 --- a/docs/usage/reading/filtering.md +++ b/docs/usage/reading/filtering.md @@ -42,7 +42,7 @@ GET /users?filter=equals(displayName,null) HTTP/1.1 GET /users?filter=equals(displayName,lastName) HTTP/1.1 ``` -Comparison operators can be combined with the `count` function, which acts on HasMany relationships: +Comparison operators can be combined with the `count` function, which acts on to-many relationships: ```http GET /blogs?filter=lessThan(count(owner.articles),'10') HTTP/1.1 @@ -60,7 +60,7 @@ GET /customers?filter=has(orders)&filter=equals(lastName,'Smith') HTTP/1.1 ``` Aside from filtering on the resource being requested (which would be blogs in /blogs and articles in /blogs/1/articles), -filtering on included collections can be done using bracket notation: +filtering on to-many relationships can be done using bracket notation: ```http GET /articles?include=author,tags&filter=equals(author.lastName,'Smith')&filter[tags]=any(label,'tech','design') HTTP/1.1 @@ -68,6 +68,8 @@ GET /articles?include=author,tags&filter=equals(author.lastName,'Smith')&filter[ In the above request, the first filter is applied on the collection of articles, while the second one is applied on the nested collection of tags. +Note this does **not** hide articles without any matching tags! Use the `has` function with a filter condition (see below) to accomplish that. + Putting it all together, you can build quite complex filters, such as: ```http @@ -112,7 +114,7 @@ Examples can be found in the table below. Filters can be combined and will be applied using an OR operator. This used to be AND in versions prior to v4.0. -Attributes to filter on can optionally be prefixed with a HasOne relationship, for example: +Attributes to filter on can optionally be prefixed with to-one relationships, for example: ```http GET /api/articles?include=author&filter[caption]=like:marketing&filter[author.lastName]=Smith HTTP/1.1