英文:
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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。


评论