1. ページネーション

SearchAfter API (V3)

日本語翻訳に関する免責事項

このページの翻訳はAIによって自動的に行われました。可能な限り正確な翻訳を心掛けていますが、原文と異なる表現や解釈が含まれる場合があります。正確で公式な情報については、必ず英語の原文をご参照ください。

SearchAfter API (V3) を使用して、検索結果の複数ページをSearchAfterRequestで順番にフェッチします。

メモ

バージョン3.0では、LoadConfigurationを使用して、応答ペイロードでリレーションをシリアル化する方法を処理します。これは、代わりにRenditionsNestedRelationsを使用していたバージョン2.0からの変更点です。

大事な

すべての検索結果がメモリに保持されるわけではありません。ページ間で検索結果の一貫性を保つには、一意で簡単に並べ替えることができるクエリ パラメーター (識別子など) を少なくとも1つ追加します。変更日を使用すると、同じ検索結果セット内のページ間を移動するときに新しいエンティティが変更された場合、一貫性のない結果が返される可能性があります。

このエンドポイントは、次のURLから入手できます。

POST http://<HOSTNAME>/api/entities/searchafter/
手記

X-ApiVersionヘッダーを3に設定する必要があります。

LINQを使用してSearchAfter APIでクエリを作成することはできません。ただし、このAPIを使用して結果をフィルタリングするのに役立つ例をいくつか紹介します。

結果をページ分割する

結果をページ分割するには、search_afterフィールドを使用して次の操作を行います。

  1. フィルターを作成して適用します。これにより、結果の最初のページが取得されます。最初のページのサイズは、フィルターのTakeパラメーターによって決まります。

  2. 結果のlast_hit_dataフィールドの値をメモします。例えば:

    "last_hit_data": [
            "1711962952348"
        ],
  3. 手順1と同じフィルターを使用し、値を含めます (例: "search_After": "1711962952348")。

    last_hit_dataはリクエストごとに変更されるため、後続の検索で更新する必要があります。

フィルター

次のフィルターがサポートされています。

サポートされている演算子

次の比較演算子は、プロパティのデータ型に応じてサポートされます。

手記

クエリでは、サポートされている任意の演算子 を使用できます。

データ型

演算子

long

==, !=

string

==, !=

int

=!=><>=<=

decimal

==!=><>=<=

bool

==, !=

DateTime

==!=<>>=<=

DateTimeOffset

==!=><>=<=

手記

文字列プロパティは、いくつかの追加フィルターをサポートしています。

  • Contains - この値には、指定した部分文字列が含まれている必要があります。

  • StartsWith -この値は、指定した部分文字列で始まる必要があります。

  • EndsWith - この値は、指定した部分文字列で終わる必要があります。

依頼

リクエストには、次のパラメータが含まれます。

  • Filter - 検索の条件を定義します。この場合、アセットは定義名( M.Assetなど)でフィルタリングされます。

  • Take - 要求ごとに取得する結果の数を指定します。

  • Sorting - 結果をフィールド ( identifierなど) ごとに昇順で並べ替えます。

  • Search_after - 最後の結果の値を使用して、次の結果セットをフェッチします。

  • LoadConfiguration - 読み込むプロパティ、カルチャ、リレーションを指定します。たとえば、カスタム設定では、Titleなどの特定のプロパティやAssetTypeToAssetなどのリレーションを読み込むことができます。

{
    "filter": {
        "name": "M.Asset",
        "type": "DefinitionName"
    },
    "take": 25,
    "sorting": [
        {
            "field": "identifier",
            "order": "Asc"
        }
    ],
    "search_after": null,
    "load_configuration": {
        "culture_option": {
            "load_option": "None"
        },
        "property_option": {
            "load_option": "Custom",
            "properties": ["Title"]
        },
        "relation_option": {
            "load_option": "Custom",
            "relations": [
                { "name": "AssetTypeToAsset" }
            ]
        }
    }
}

応答

応答はEntityCollectionResourceオブジェクトを返し、次のパラメーターを含めることができます。

  • Last_hit_data - 現在のページの最後のアイテムの識別子を保持し、結果の次のページを取得するために使用されます。

  • Items - 取得したエンティティと、そのプロパティ、リレーション、およびメタデータ ( created_bymodified_onpermissionsrenditionsなど) が含まれます。

  • TotalItems/ReturnedItems - クエリに一致する項目の合計数と、現在の応答で返された項目の数が表示されます。

{
    "last_hit_data": [
        "asset.11154snackingindulgent"
    ],
    "items": [
        {
            "id": 34994,
            "identifier": "asset.11154SnackingIndulgent",
            "cultures": [],
            "properties": {
                "Title": "Snacking: indulgent or essential to a healthy diet",
                "FileName": "11154-Snacking-Indulgent-or-Essential-to-a-healthy-diet.pdf"
            },
            "relations": {
                "AssetTypeToAsset": {
                    "parent": {
                        "href": "https://localhost:8180/api/entities/34623"
                    },
                    "self": {
                        "href": "https://localhost:8180/api/entities/34994/relations/AssetTypeToAsset"
                    }
                }
            },
            "created_by": {
                "href": "https://localhost:8180/api/entities/6",
                "title": "The user who created the entity"
            },
            "created_on": "2024-10-14T19:19:20.7721363Z",
            "modified_by": {
                "href": "https://localhost:8180/api/entities/6",
                "title": "The user who last modified the entity"
            },
            "modified_on": "2024-10-14T19:33:17.361439Z",
            "entitydefinition": {
                "href": "https://localhost:8180/api/entitydefinitions/M.Asset",
                "title": "The entity definition for this entity"
            },
            "copy": {
                "href": "https://localhost:8180/api/entities/34994/copy",
                "title": "Copy this entity"
            },
            "permissions": {
                "href": "https://localhost:8180/api/entities/34994/permissions",
                "title": "The permissions on this entity"
            },
            "lifecycle": {
                "href": "https://localhost:8180/api/entities/34994/lifecycle",
                "title": "The lifecycle action for this entity."
            },
            "saved_selections": {
                "href": "https://localhost:8180/api/entities/34994/savedselections",
                "title": "The saved selections this entity belongs to"
            },
            "roles": {
                "href": "https://localhost:8180/api/entities/34994/roles",
                "title": "Roles for this entity"
            },
            "annotations": {
                "href": "https://localhost:8180/api/entities/34994/annotations",
                "title": "Annotations for this entity"
            },
            "is_root_taxonomy_item": false,
            "is_path_root": true,
            "inherits_security": true,
            "is_system_owned": false,
            "version": 4,
            "self": {
                "href": "https://localhost:8180/api/entities/34994"
            },
            "related_paths": {
                "AssetTypeToAsset": [
                    [
                        {
                            "values": {
                                "en-US": "Social Media Asset"
                            },
                            "entity": "https://localhost:8180/api/entities/34623",
                            "definition": "https://localhost:8180/api/entitydefinitions/M.AssetType"
                        }
                    ]
                ]
            },
            "renditions": {
                "downloadOriginal": [
                    {
                        "href": "https://localhost:5009/api/delivery/local-6c8a7bc9c26c4f95a8c6451c0384e3f2?intent=Download&expires=2024-10-14T19%3A55%3A10.2949693%2B00%3A00&entityid=34994&userid=6&rendition=downloadOriginal&signature=pLKt5ST6Qok"
                    }
                ],
                "downloadAlternative": [
                    {
                        "href": "https://localhost:5009/api/delivery/local-6c8a7bc9c26c4f95a8c6451c0384e3f2?intent=Download&expires=2024-10-14T19%3A55%3A10.2980889%2B00%3A00&entityid=34994&userid=6&rendition=downloadAlternative&signature=7RTHFkWHc0s"
                    }
                ]
            }
        }
    ],
    "total_items": 249,
    "returned_items": 1
}

リレーションのロードオプションがNoneに設定されている場合、すべてのリレーションがリンクとして返されます。例えば:

 "AssetTypeToAsset": {
    "self": {
        "href": "https://localhost:8180/api/entities/12345/relations/AssetTypeToAsset"
    }
}

それ以外の場合は、リレーションリンクとして返されます。例えば:

 "AssetTypeToAsset": {
    "parent": {
       "href": "https://localhost:8180/api/entities/34623"
    },
       "self": {
          "href": "https://localhost:8180/api/entities/34994/relations/AssetTypeToAsset"
    }
}
この記事を改善するための提案がある場合は、 お知らせください!