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