Microsoft Search API を使用して検索結果を xrank する

Microsoft Graph の Microsoft Search API XRANK 式を使用すると、クエリに一致する項目を変更することなく、一致式内の特定の用語の出現に基づいて項目の動的ランクを向上させることができます。 XRANK 式には、一致する必要がある 1 つのコンポーネント、一致式、および動的ランク付けにのみ使用される 1 つ以上のコンポーネント (ランク式) が含まれています。 XRANK 式を有効にするためには、少なくともパラメーターの 1 つ (n を除く) を指定する必要があります。 xrank 演算子は、SharePoint でホストされているファイルでのみサポートされます。

XRANK 演算子は次の構文で使用します。

<match expression> XRANK(cb=100, rb=0.4, pb=0.4, avgb=0.4, stdb=0.4, nb=0.4, n=200) <rank expression>

XRANK 演算子の動的ランク付け計算の詳細については、「 動的ランク付け演算子」を参照してください。

次の例は、SharePoint でホストされているファイルを検索し、 XRANK 演算子 を使用して指定した検索結果をブーストする要求を示しています。

XRANK なしの要求

POST https://graph.microsoft.com/v1.0/search/query
Content-Type: application/json

{
    "requests": [
        {
            "entityTypes": [
                "listItem"
            ],
            "query": {
                "queryString": "cat OR dog"
            },
            "from": 0,
            "size": 1
        }
    ]
}

応答

HTTP/1.1 200 OK
Content-type: application/json
{
    "value": [
        {
            "searchTerms": [
                "cat",
                "dog"
            ],
            "hitsContainers": [
                {
                    "hits": [
                        {
                            "hitId": "32faa5c0-0bd5-4918-a19c-7b3c415a0fb4",
                            "rank": 1,
                            "summary": "this program has changed any times over the years, but one of the most common is “<c0>dog</c0> food <ddd/> However, only a few of those will get focused attention through the “<c0>dog</c0> food” process <ddd/> ",
                            "resource": {
                                "@odata.type": "#microsoft.graph.listItem",
                                "createdDateTime": "2021-04-22T19:22:23Z",
                                "lastModifiedDateTime": "2021-12-03T19:00:27Z",
                                "webUrl": "https://microsoft.sharepoint.com/teams/Employee_Experience/SitePages/Dog-Foodxxxxx.aspx"
                            }
                        }
                    ],
                    "total": 616865,
                    "moreResultsAvailable": true
                }
            ]
        }
    ],
    "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#Collection(microsoft.graph.searchResponse)"
}

XRANK を使用した要求

POST https://graph.microsoft.com/v1.0/search/query
Content-Type: application/json

{
    "requests": [
        {
            "entityTypes": [
                "listItem"
            ],
            "query": {
                "queryString": "(cat OR dog) XRANK(cb=100) note"
            },
            "from": 0,
            "size": 1
        }
    ]
}

応答

HTTP/1.1 200 OK
Content-type: application/json

{
    "value": [
        {
            "searchTerms": [
                "cat",
                "dog",
                "note"
            ],
            "hitsContainers": [
                {
                    "hits": [
                        {
                            "hitId": "cb32ce8e-7f82-4b1d-b1fb-52e6af95fbed",
                            "rank": 1,
                            "summary": "Microsoft is committed to providing a <ddd/> Other than meeting rooms marked as <c0>dog</c0>-free, meeting organizers can decide on a case-specific basis whether to disallow <c0>dogs</c0> in their meetings <ddd/> ",
                            "resource": {
                                "@odata.type": "#microsoft.graph.listItem",
                                "createdDateTime": "2020-09-21T04:46:40Z",
                                "lastModifiedDateTime": "2022-09-18T09:15:18Z",
                                "webUrl": "https://microsofteur.sharepoint.com/teams/insider/EN/SitePages/Dog-Policy.aspx"
                            }
                        }
                    ],
                    "total": 616865,
                    "moreResultsAvailable": true
                }
            ]
        }
    ],
    "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#Collection(microsoft.graph.searchResponse)"
}

既知の制限

XRANK 式は、messagechatMessageeventperson、または externalItem というリソースではサポートされていません。

次の手順