在内容丰富的多个参考字段上搜索
Searching on multiple reference fields in contentful
我想弄清楚如何根据作者(参考)检索特定文章,我当前的函数检索所有文章,但我只想要作者特定的文章
const resp = yield client.getEntries({
'fields.insightsArticle': true,
'fields.excludeCountries[nin]': country,
'fields.publicationDate[lte]': moment(new Date()).toISOString(),
'fields.author.fields.firstname': author.firstName,
'fields.author.fields.lastname': author.lastName,
content_type: 'insight',
include: 2,
order: '-fields.publicationDate',
limit,
locale,
});
我从 contentful 获得的当前日志是:
"When searching on references you must specify the Content Type of the reference. Please send a Content Type id as a query parameter"
我明白了,因为我将内容类型定义为见解。
欢迎提出任何建议!
我遇到了同样的问题!您可以通过添加以下内容来指定引用的内容类型:
'fields.author.sys.contentType.sys.id': 'author'
此外,我会将 content_type: 'insight' 行作为第一个条目并删除限制和区域设置,因为您没有使用这些字段。
我想弄清楚如何根据作者(参考)检索特定文章,我当前的函数检索所有文章,但我只想要作者特定的文章
const resp = yield client.getEntries({
'fields.insightsArticle': true,
'fields.excludeCountries[nin]': country,
'fields.publicationDate[lte]': moment(new Date()).toISOString(),
'fields.author.fields.firstname': author.firstName,
'fields.author.fields.lastname': author.lastName,
content_type: 'insight',
include: 2,
order: '-fields.publicationDate',
limit,
locale,
});
我从 contentful 获得的当前日志是: "When searching on references you must specify the Content Type of the reference. Please send a Content Type id as a query parameter"
我明白了,因为我将内容类型定义为见解。
欢迎提出任何建议!
我遇到了同样的问题!您可以通过添加以下内容来指定引用的内容类型:
'fields.author.sys.contentType.sys.id': 'author'
此外,我会将 content_type: 'insight' 行作为第一个条目并删除限制和区域设置,因为您没有使用这些字段。