Contentful API查询不带标签的条目

huangapple go评论112阅读模式
英文:

Contentful API query for entries that do not have a tag

问题

有没有一种查询不包含特定标签的条目的方法?例如,获取除了具有“featured”标签的条目之外的所有条目。

英文:

Is there a way to query for entries that don't have a specific tag?

As per the docs to get a collection of entries based with a set of tags we can use metadata.tags.sys.id[all]=tagA,tagB

e.g.

/spaces/yadj1kx9rmg0/environments/staging/entries?access_token=fdb4e7a3102747a02ea69ebac5e282b9e44d28fb340f778a4f5e788625a61abe&metadata.tags.sys.id[all]=tagA,tagB

or we can get a collection of entries that have at least one tag from a list like this metadata.tags.sys.id[in]=tagA,tagB

e.g.

/spaces/yadj1kx9rmg0/environments/staging/entries?access_token=fdb4e7a3102747a02ea69ebac5e282b9e44d28fb340f778a4f5e788625a61abe&metadata.tags.sys.id[in]=tagA,tagB 

The 'exists' query appears to test for the existence of any tags metadata.tags[exists]=true not a specific tag.

Is there a way to get a collection that doesn't contain a tag? For example to get all entries except those that have the 'featured' tag.

答案1

得分: 0

可以使用 nin 来实现这一点,如下所示:metadata.tags.sys.id[nin]=tagA,TagB。这将返回不包含你提供的一个或多个逗号分隔标签的项。

英文:

This can be done with nin like this: metadata.tags.sys.id[nin]=tagA,TagB

It will return items which do not have one or more of the comma separated tags you supply.

huangapple
  • 本文由 发表于 2023年3月7日 20:30:53
  • 转载请务必保留本文链接:https://go.coder-hub.com/75661992.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定