5

私の現在のプロジェクトでContentfulを利用しようとしています.リンクされたオブジェクトのフィールドに基づいてクエリ結果をフィルタリングする方法を理解しようとしています.

私の最上位オブジェクトには、次のように定義された Link が含まれています。

  "name": "Service_Description",
  "fields": [
{
  "name": "Header",
  "id": "header",
  "type": "Link",
  "linkType": "Entry",
  "required": true,
  "validations": [
    {
      "linkContentType": [
        "offerGeneral"
      ]
    }
  ],
  "localized": false,
  "disabled": false,
  "omitted": false
},

この「ヘッダー」フィールドは、次の定義を持つ別のコンテンツ タイプにリンクしています。

  "fields": [
{
  "name": "General",
  "id": "general",
  "type": "Link",
  "linkType": "Entry",
  "required": true,
  "validations": [
    {
      "linkContentType": [
        "genericGeneral"
      ]
    }
  ],
  "localized": false,
  "disabled": false,
  "omitted": false
},

次に、最下位レベルにリンクします。

"fields": [{
  "name": "TagList",
  "id": "tagList",
  "type": "Array",
  "items": {
    "type": "Link",
    "linkType": "Entry",
    "validations": [
      {
        "linkContentType": [
          "tag"
        ]
      }
    ]
  },
  "validations": []
}

ここで、tagList は、このコンテンツが持つ可能性のあるタグの配列です。

提供されたタグのリストからのタグを含む、これらの「Service_Description」コンテンツエントリを X 個取得するという最上位オブジェクトからのクエリを実行できるようにしたいと考えています。

PostMan では、次のように実行しています。

https://cdn.contentful.com/spaces/{SPACE_ID}/entries?access_token={ACCESS_TOKEN}&content_type=serviceDescription&include=3

次のようなフィルターを追加しようとしています。

fields.header.fields.general.fields.tagList.sys.id%5Bin%5D={TAG_SYS_ID}

これは明らかに間違っていますが、目標を達成するためにこの関係をどのように歩むかについて、私は苦労してきました. ドキュメントを熟読すると、これはインクルードと関係があるようですが、問題を修正する方法がわかりません。

私の目標を達成する方法、またはこれが可能かどうかについての指示はありますか?

4

2 に答える 2

2

Unfortunately what you are requesting is not currently possible in Contentful.

We were facing a very similar issue with nested/referenced content types and support said it wasn't possible.

We ended up writing a very complicated system that allowed us to do what you want. Essentially doing a full text search for the referenced content and then querying all of the parents entries. We then matched the relationships by iterating over the parents to find the relationship.

Sorry it couldn't be easier. Hopefully the devs work on something that improve this complication. We have brought this to their attention.

于 2016-07-05T13:10:02.520 に答える