Drupal9 JSON:API 在段落内容上进行筛选

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

Drupal9 JSON:API filtering on Paragraphs content

问题

我有一个 JSON API 端点,可以根据包含搜索词的标题进行搜索:
/jsonapi/node/article?filter[title][operator]=CONTAINS&filter[title][value]=search term

但我还有一个需要在筛选器中使用的段落字段,所以如果标题或段落字段包含搜索词,然后返回文章。

我尝试了各种筛选段落字段的方法,但无法得到任何返回:
filter[paragraph_field][operator]=CONTAINS&filter[paragraph_field][value]=search term

我确信这是可能的,因为段落的一个功能被陈述为“实体,因此:可导出字段基/实例,可在搜索 API 中使用,可在视图中使用”。

英文:

I have a json api endpoint that I can search on title that contains a term:
/jsonapi/node/article?filter[title][operator]=CONTAINS&filter[title][value]=search term

But I also have a Paragraphs field that I need to use in the filter, so if the title or Paragraphs field contain the search term then return the article

I have tried various way of filtering against the Paragraph field but can't get anything back:
filter[paragraph_field][operator]=CONTAINS&filter[paragraph_field][value]=search term

I'm sure this is possible as one of the Features of Paragraphs is stated as 'Entities, so: exportable field bases/instances, usable in Search API, usable in Views'

答案1

得分: 0

我明白了,错误中有一个提示;关键是在键中正确设置路径:

?filter[field_paragraphs.field_body.value][operator]=CONTAINS
&filter[field_paragraphs.field_body.value][value]=search term
英文:

I figured it, there was a hint in the error; it's a matter of getting the path correct in the key:

?filter[field_paragraphs.field_body.value][operator]=CONTAINS
&filter[field_paragraphs.field_body.value][value]=search term

huangapple
  • 本文由 发表于 2023年6月8日 02:27:34
  • 转载请务必保留本文链接:https://go.coder-hub.com/76426130.html
匿名

发表评论

匿名网友

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

确定