ルールの追加

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

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

widget.items.search.ruleオブジェクトを使用して、特定の結果項目の処理方法Sitecore Search構成できます。アイテムやカテゴリをブラックリストに登録したり、ブーストしたり、埋めたり、含めたり、ピン留めしたりできます。pinルールを除き、ルールを適用する項目を指定するには、ruleオブジェクト内にfilterオブジェクトを入れ子にする必要があります。

このオブジェクトのデータモデルについては、Search and Recommendation APIリファレンスを参照してください。

メモ

API要求で渡すルールは、Sitecore Searchで設定されたルールを上書きします。

アイテムをスロットにブーストする

アイテムまたはカテゴリをスロットにブーストするには、widget.items.search.rule.boostオブジェクトを追加します。ブーストする商品またはカテゴリ、およびそれらを表示したいスロットを指定する必要があります。

この例では、

  • productカテゴリのすべてのアイテムをブーストしたいと考えています。

  • ブーストされた項目を検索結果のスロット2と3に表示します。

次のコードは、サンプル要求を示しています。

{
    "widget": {
        "items": [
            {
                "rfk_id": "rfkid_7",
                "entity": "content",
                "search": {
                    "content": {},
                    "rule": {
                        "boost": [
                            {
                                "filter": {
                                    "type": "eq",
                                    "name": "type",
                                    "value": "products"
                                },
                                "slots": [
                                    2,
                                    3
                                ]
                            }
                        ]
                    }
                }
            }
        ]
    },
    "context": {
        "locale": {
            "country": "us",
            "language": "en"
        },
        "user": {
            "uuid": "159871551-1g-i4-4x-1p-f5tdhddqwvywv7b9g2vy-1664852644904"
        }
    }
}

要求に対する応答は次のとおりです。

        {
            "rfk_id": "rfkid_7",
            "entity": "content",
            "content": [
                {
                    "description": "Premier Assure is designed...",
                    "id": "https___www_sitecore_com_activities",
                    "image": "https:imageurl/activities/gettyimages-699087272-hero.jpg?md=20220921T172222Z",
                    "image_type": "Image",
                    "image_url": "www.imageur.com",
                    "last_modified": "2022-10-19 20:57:04Z",
                    "source_id": "407033",
                    "subtitle": "Improve the quality of your Sitecore investment using a review-based approach.",
                    "title": "Premier Assure services: assuring confidence in your investment",
                    "type": "Knowledge Center",
                    "url": "https://www.sitecore.com/activities"
                },
                {
                    "description": "Sitecore CDP Connector for Responsys...",
                    "id": "https___www_sitecore_com_products_marketplace_tap_cdp_sitecore-cdp-connector-for-responsys",
                    "source_id": "388218",
                    "subtitle": null,
                    "title": "Sitecore CDP Connector for Responsys",
                    "type": "products",
                    "url": "https://www.sitecore.com/products/marketplace/tap/cdp/sitecore-cdp-connector-for-responsys"
                },
                {
                    "description": "Sitecore CDP Integration for Amazon Sagemaker...",
                    "source_id": "388218",
                    "subtitle": null,
                    "title": "Sitecore CDP Integration for Amazon Sagemaker",
                    "type": "products",
                    "url": "https://www.sitecore.com/products/marketplace/tap/cdp/sitecore-cdp-integration-for-amazon-sagemaker"
                },
                {
                    "description": "Related topicsResource hubPersonalizationEnable customer connections with your brand...",
                    "id": "https___www_sitecore_com_content-management",
                    "image": "https:imageurl/content-gettyimages-691574517-original2.jpg?md=20220107T002955Z",
                    "image_type": "Image",
                    "image_url": "https:imageurl/588D7FE5D8C&t=544x310",
                    "last_modified": "2022-05-25 19:52:23Z",
                    "source_id": "407033",
                    "subtitle": "Content fuels the digital experience in just about every industry.",
                    "title": "Content resources",
                    "type": "Knowledge Center",
                    "url": "https://www.sitecore.com/content-management"
                }
                ...
            ],
            "total_item": 5856,
            "limit": 10,
            "offset": 0
        }
    ],
    "dt": 109,
    "ts": 1669433189900
}

応答contentオブジェクトでは、2番目と3番目の結果項目、つまりスロット2と3にproduct項目が表示されます。

スロットのないアイテムのブースト

スロットを指定せずにアイテムまたはカテゴリをブーストするには、widget.items.search.rule.boostオブジェクトを使用します。ブーストしたい製品またはカテゴリと、ブーストする重量を指定する必要があります。

この例では、

  • 訪問者はキーワードcontentを検索します。

  • すべてのブログを5の重みでブーストしたいと考えています。

{
    "widget": {
        "items": [
            {
                "entity": "content",
                "rfk_id": "rfkid_7",
                "search": {
                    "content": {},
                    "rule": {
                        "boost": [
                            {
                                "weight": 4,
                                "filter": {
                                    "type": "eq",
                                    "name": "type",
                                    "value": "Blogs"
                                }
                            }
                        ]
                    },
                    "personalization": {
                        "fields": [
                            "title",
                            "type"
                        ]
                    },
                    "limit": 10,
                    "offset": 0,
                    "query": {
                        "keyphrase": "content"
                    }
                },
                "sources": [
                    "407033",
                    "408162"
                ]
            }
        ]
    },
    "context": {
        "locale": {
            "country": "us",
            "language": "en"
        },
        "user": {
            "uuid": "159871551-ye-l5-4u-1p-0z7apweb0jxcibpfzr40-1663129543566"
        }
    }
}

項目をブラックリストに登録する

項目またはカテゴリのリストをブラックリストに登録するには、search.rule.blacklistオブジェクトを追加します。これらの項目やカテゴリは、検索結果に表示されません。

この例では、タイプotherのすべてのコンテンツをブラックリストに登録します。次のコードは、サンプル要求を示しています。

{
    "widget": {
        "items": [
            {
                "rfk_id": "rfkid_7",
                "entity": "content",
                "search": {
                    "content": {},
                    "rule": {
                        "blacklist": {
                            "filter": {
                                "type": "eq",
                                "name": "type",
                                "value": "other"
                            }
                        }
                    }
                }
            }
        ]
    },
    "context": {
        "locale": {
            "country": "us",
            "language": "en"
        },
        "user": {
            "uuid": "159871551-1g-i4-4x-1p-f5tdhddqwvywv7b9g2vy-1664852644904"
        }
    }
}

要求に対する応答は次のとおりです。

{
    "widgets": [
        {
            "rfk_id": "rfkid_7",
            "entity": "content",
            "content": [
                {
                    "description": "Discover top moments...",
                    "id": "https___www_sitecore_com",
                    "image": "https:imageurl.com/sitecore-home-hero-v01-052722_72dpi.jpg?md=20220627T124154Z",
                    "last_modified": "2022-11-18 16:46:12Z",
                    "source_id": "407033",
                    "subtitle": "Digital Experience Platform and Content Hub that apply the power of data science and marketing technology to shape your business around new possibilities.",
                    "title": "Turn consumers into fans",
                    "type": "Others",
                    "url": "https://www.sitecore.com"
                },
                {
                    "description": "It captures data...",
                    "id": "https___www_sitecore_com_blog_digital-transformation_7-business-benefits-of-a-customer-data-platform",
                    "image": "https:imageurl.com/gettyimages-1299625060_insights_feature.png?md=20220224T144643Z",
                    "image_url": "https://imageurl.com/79E042A6C3001AB18B&t=544x310",
                    "last_modified": "2022-04-05 04:57:22Z",
                    "product": "Customer Data Platform",
                    "source_id": "407033",
                    "subtitle": "From smashing data silos and building loyalty, to driving revenue, our blog explores 7 transformative business effects of a customer data platform.",
                    "title": "7 business benefits of a customer data platform",
                    "type": "Others",
                    "url": "https://www.sitecore.com/blog/digital-transformation/7-business-benefits-of-a-customer-data-platform"
                }, 

        ...
            ],
            "total_item": 4934,
            "limit": 10,
            "offset": 0
        }
    ],
    "dt": 30,
    "ts": 1669054635432
}

応答contentオブジェクトでは、typeotherの項目がないことがわかります。

アイテムのピン留め

検索結果の特定のスロットにアイテムをピン留めするには、search.rule.pinオブジェクトを使用して、使用するスロットとピン留めするアイテムのIDを指定します。

この例では、クラウド コンピューティングに関するブログをスロット番号2にピン留めします。

次のコードは、サンプル要求を示しています。

{
    "widget": {
        "items": [
            {
                "rfk_id": "rfkid_7",
                "entity": "content",
                "sources": [
                    "388218",
                    "390565"
                ],
                "search": {
                    "content": {},
                    "rule": {
                        "pin": [
                            {
                                "slot": 2,
                                "id": "https___www_sitecore_com_blog_cloud_cloud-computing-in-business-and-the-future-of-cx"
                            }
                        ]
                    }
                }
            }
        ]
    },
    "context": {
        "locale": {
            "country": "us",
            "language": "en"
        },
        "user": {
            "uuid": "159871551-1g-i4-4x-1p-f5tdhddqwvywv7b9g2vy-1664852644904"
        }
    }
}

要求に対する応答は次のとおりです。

{
    "widgets": [
        {
            "rfk_id": "rfkid_7",
            "entity": "content",
            "content": [
                {
                    "description": "October 13, 2021...",
                    "id": "https___www_sitecore_com_company_news-events_news_2021_10_majority-of-mena-brands-changed-customer-experiences-due-to-the-pandemic",
                    "source_id": "388218",
                    "subtitle": null,
                    "title": "Khaleej Times: Majority of Mena brands changed customer experiences due to the pandemic",
                    "type": "news",
                    "url": "https://www.sitecore.com/company/news-events/news/2021/10/majority-of-mena-brands-changed-customer-experiences-due-to-the-pandemic"
                },
                {
                    "description": "Companies that survived...",
                    "id": "https___www_sitecore_com_blog_cloud_cloud-computing-in-business-and-the-future-of-cx",
                    "image_url": "https://imageurl/cloud-computing-in-business-and-the-future-of-cx/gettyimages-1209700460_heromedium_mb.jpg?mw=600&md=20211006T181735Z&hash=827DB91BE20225F7C4BEFDF36BDD0249&t=544x310",
                    "source_id": "388218",
                    "subtitle": "How CIOs can lead organizational transformation starting with marketing.",
                    "title": "Cloud computing in business and the future of CX",
                    "type": "blogs",
                    "url": "https://www.sitecore.com/blog/cloud/cloud-computing-in-business-and-the-future-of-cx"
                }, 

        ...
            ],
            "total_item": 2881,
            "limit": 10,
            "offset": 0
        }
    ],
    "dt": 52,
    "ts": 1669054542978
}

応答contentオブジェクトでは、検索結果の2番目の項目として、スロット番号2に目的のブログが表示されます。

この記事を改善するための提案がある場合は、 お知らせください!