Freigeben über


Verwenden der Microsoft Search-API zum Suchen mit verschachtelten Ergebnissen

Die Microsoft Search searchRequest-Ressource unterstützt die Übergabe mehrerer Entitätstypen in einer einzelnen Anforderung und gibt überlappende Ergebnisse mit den angeforderten Entitätstypen zurück, die nach Relevanz sortiert sind.

Unterstützte Entitätskombinationen

Die folgende Tabelle zeigt die Beziehung zwischen verschiedenen Entitätstypen, die verschachtelt werden können. Der Entitätstyp qna wird nur in der Betaversion unterstützt.

Entitätstyp acronym bookmark message ChatMessage Laufwerk driveItem event externalItem Liste listItem Person qna Website
acronym True True - - - - - - - - - True -
bookmark True True - - - - - - - - - True -
message - - True True - - - - - - - - -
ChatMessage - - True True - - - - - - - - -
Laufwerk - - - - True True - True True True - - True
driveItem - - - - True True - True True True - - True
event - - - - - - Wahr - - - - - -
externalItem - - - - True True - True True True - - True
Liste - - - - True True - True True True - - True
listItem - - - - True True - True True True - - True
Person - - - - - - - - - - Wahr - -
qna True True - - - - - - - - - True -
Website - - - - True True - True True True - - True

Beispiele

Beispiel 1: Search mit SharePoint-Dateitypen und der Kombination aller Connectors

Das folgende Beispiel zeigt eine Anforderung, die mit SharePoint-Dateitypen und allen Kombinationen von Connectors sucht.

Anforderung

Das folgende Beispiel zeigt eine Anfrage.

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

{
  "requests": [
    {
      "entityTypes": [
        "listItem",
        "site",
        "externalItem"
      ],
      "query": {
        "queryString": "contoso"
      },
      "contentSources": [
        "/external/connections/*"
      ],
      "from": 0,
      "size": 25
    }
  ]
}

Antwort

Das folgende Beispiel zeigt die überlappende Antwort.

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

{
  "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#search",
  "value": [
    {
      "searchTerms": [
        "contoso"
      ],
      "hitsContainers": [
        {
          "total": 4,
          "moreResultsAvailable": false,
          "hits": [
            {
              "hitId": "adce5789-c324-485a-a8bf-66bb809527ff",
              "rank": 1,
              "summary": "Test listItem 1",
              "resource": {
                "@odata.type": "#microsoft.graph.listItem",
                "createdDateTime": "2019-10-07T10:00:08Z",
                "lastModifiedDateTime": "2019-10-07T10:00:11Z",
                "title": "Here is a summary of your messages from last week -   New Feature: Live captions in English-US a"
              }
            },
            {
              "hitId": "microsoft.sharepoint.com,9fb3f597-167e-4c3d-b5e6-1ddc18d22d48,c53cd46e-9033-4b42-af94-0ad76ab75fd0",
              "rank": 2,
              "summary": "Test site",
              "resource": {
                "@odata.type": "#microsoft.graph.site",
                "createdDateTime": "2019-10-07T10:00:08Z",
                "lastModifiedDateTime": "2019-10-07T10:00:11Z",
                "title": "Test site summary"
              }
            },
            {
              "hitId": "ad60906b-1317-495c-b566-7b8ce1be5555",
              "rank": 4,
              "summary": "Test listItem 2",
              "resource": {
                "@odata.type": "#microsoft.graph.listItem",
                "createdDateTime": "2019-10-07T10:00:08Z",
                "lastModifiedDateTime": "2019-10-07T10:00:11Z",
                "title": "Test listItem summary 2"
              }
            }
          ]
        }
      ]
    }
  ]
}

Beispiel 2: Search mit SharePoint-Dateitypen und einer bestimmten Connectorkombination

Das folgende Beispiel zeigt eine Anforderung, die mit SharePoint-Dateitypen und einer bestimmten Kombination von Connectors sucht.

Anforderung

Das folgende Beispiel zeigt eine Anfrage.

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

{
  "requests": [
    {
      "entityTypes": [
        "listItem",
        "site",
        "externalItem"
      ],
      "query": {
        "queryString": "contoso"
      },
      "contentSources": [
        "/external/connections/MicrosoftPowerBI",
        "/external/connections/Learning"
      ],
      "from": 0,
      "size": 25
    }
  ]
}

Antwort

Das folgende Beispiel zeigt die überlappende Antwort.

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

{
  "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#search",
  "value": [
    {
      "searchTerms": [
        "contoso"
      ],
      "hitsContainers": [
        {
          "total": 5,
          "moreResultsAvailable": false,
          "hits": [
            {
              "hitId": "adce5789-c324-485a-a8bf-66bb809527ff",
              "rank": 1,
              "summary": "Test listItem 1",
              "resource": {
                "@odata.type": "#microsoft.graph.listItem",
                "createdDateTime": "2019-10-07T10:00:08Z",
                "lastModifiedDateTime": "2019-10-07T10:00:11Z",
                "title": "Here is a summary of your messages from last week -   New Feature: Live captions in English-US a"
              }
            },
            {
              "hitId": "microsoft.sharepoint.com,9fb3f597-167e-4c3d-b5e6-1ddc18d22d48,c53cd46e-9033-4b42-af94-0ad76ab75fd0",
              "rank": 2,
              "summary": "Test site",
              "resource": {
                "@odata.type": "#microsoft.graph.site",
                "createdDateTime": "2019-10-07T10:00:08Z",
                "lastModifiedDateTime": "2019-10-07T10:00:11Z",
                "title": "Test site summary"
              }
            },
            {
              "hitId": "adce5789-c324-485a-a8bf-66bb809527ff=",
              "rank": 3,
              "summary": "Test externalItem",
              "contentSource": "MicrosoftPowerBI",
              "resource": {
                "@odata.type": "#microsoft.graph.externalConnectors.externalItem",
                "title": "Test externalItem summary",
              }
            },
            {
              "hitId": "adce5789-c324-485a-a8bf-66bb809527ff=",
              "rank": 4,
              "summary": "Learning externalItem",
              "contentSource": "Learning",
              "resource": {
                "@odata.type": "#microsoft.graph.externalConnectors.externalItem",
                "title": "Test externalItem summary",
              }
            },
            {
              "hitId": "ad60906b-1317-495c-b566-7b8ce1be5555",
              "rank": 5,
              "summary": "Test listItem 2",
              "resource": {
                "@odata.type": "#microsoft.graph.listItem",
                "createdDateTime": "2019-10-07T10:00:08Z",
                "lastModifiedDateTime": "2019-10-07T10:00:11Z",
                "title": "Test listItem summary 2"
              }
            }
          ]
        }
      ]
    }
  ]
}

Beispiel 3: Search mit Kombination aus Lesezeichen und Akronym

Das folgende Beispiel zeigt eine Anforderung, die mit Lesezeichen und Akronym als Entitätstypen sucht.

Anforderung

Das folgende Beispiel zeigt eine Anfrage.

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

{
  "requests": [
    {
      "entityTypes": [
        "bookmark",
        "acronym"
      ],
      "query": {
        "queryString": "POC"
      },
      "from": 0,
      "size": 25
    }
  ]
}

Antwort

Das folgende Beispiel zeigt die überlappende Antwort für Lesezeichen und Akronym.

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

{
  "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#search",
  "value": [
    {
      "searchTerms": [
        "POC"
      ],
      "hitsContainers": [
        {
          "total": 2,
          "moreResultsAvailable": false,
          "hits": [
            {
              "hitId": "adce5789-c324-485a-a8bf-66bb809527ff",
              "rank": 1,
              "summary": "",
              "resource": {
                "@odata.type": "#microsoft.graph.search.acronym",
                "id": "adce5789-c324-485a-a8bf-66bb809527ff",
                "displayName": "POC",
                "description": "Acronym in Spanish",
                "webUrl": "",
                "standsFor": "prueba de concepto"
              }
            },
            {
              "hitId": "1c0599db-2e89-4327-827a-3935c999f6cc",
              "rank": 2,
              "summary": "",
              "resource": {
                "@odata.type": "#microsoft.graph.search.bookmark",
                "id": "1c0599db-2e89-4327-827a-3935c999f6cc",
                "displayName": "POC",
                "description": "A proof of concept (POC) is an exercise in which work is focused on determining whether an idea can be turned into a reality. ",
                "webUrl": "https://en.wikipedia.org/wiki/POC"
              }
            }
          ]
        }
      ]
    }
  ]
}

Beispiel 4: Verschachteln von Teams und Outlook-Inhalten

Das folgende Beispiel zeigt, wie Sie Teams-Chatnachrichten und Outlook-Nachrichteninhalte verschachteln.

Anforderung

Das folgende Beispiel zeigt eine Anfrage.

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

{
    "requests": [
        {
            "entityTypes": [
                "chatMessage",
                "message"
            ],
            "query": {
                "queryString": "*"
            },
            "from": 0,
            "size": 5
        }
    ]
}

Antwort

Das folgende Beispiel zeigt die überlappende Antwort.

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

{
    "value": [
        {
            "searchTerms": [],
            "hitsContainers": [
                {
                    "hits": [
                        {
                            "hitId": "AQMkAGNhZjFkYzQ3LTc2MDYtNGZiMS04ZGE3LTQ2MjUyZmRlMzA0NgBGAAAD7MLXbKjTeUeUiM62OAqxBAcA/PUmjl3OgEumTcnPoOXsegAAAgFYAAAA/PUmjl3OgEumTcnPoOXsegABBugTfgAAAA==",
                            "rank": 1,
                            "summary": "hi",
                            "resource": {
                                "@odata.type": "microsoft.graph.chatMessage",
                                "id": "1657786709667",
                                "createdDateTime": "2022-07-14T08:18:30Z",
                                "lastModifiedDateTime": "2022-07-14T08:19:07Z",
                                "subject": "",
                                "importance": "normal",
                                "webLink": "https://teams.microsoft.com/l/message/19%3a8b00f92f-63ba-4ad7-822e-862219ba93b3_ba9f3156-32ae-4308-bd33-64a92319b578%40unq.gbl.spaces/1657786709667?context=%7B%22contextType%22:%22chat%22%7D",
                                "from": {
                                    "emailAddress": {
                                        "name": "Tong Zheng",
                                        "address": "Tong.Zheng@microsoft.com"
                                    }
                                },
                                "channelIdentity": {
                                    "channelId": "19:8b00f92f-63ba-4ad7-822e-862219ba93b3_ba9f3156-32ae-4308-bd33-64a92319b578@unq.gbl.spaces"
                                },
                                "etag": "1657786709667",
                                "chatId": "19:8b00f92f-63ba-4ad7-822e-862219ba93b3_ba9f3156-32ae-4308-bd33-64a92319b578@unq.gbl.spaces"
                            }
                        },
                        {
                            "hitId": "AQMkAGNhZjFkYzQ3LTc2MDYtNGZiMS04ZGE3LTQ2MjUyZmRlMzA0NgBGAAAD7MLXbKjTeUeUiM62OAqxBAcA-PUmjl3OgEumTcnPoOXsegAAAgEBAAAAAPz1Jo5dzoBLpk3Jz6Dl7HoAAAIJWgAAAA==",
                            "rank": 2,
                            "summary": "",
                            "resource": {
                                "@odata.type": "#microsoft.graph.message",
                                "createdDateTime": "2021-06-11T23:17:11Z",
                                "lastModifiedDateTime": "2021-06-12T02:58:00Z",
                                "receivedDateTime": "2021-06-11T23:17:11Z",
                                "sentDateTime": "2021-06-11T23:17:11Z",
                                "hasAttachments": false,
                                "internetMessageId": "<DM5PR00MB0406C60478A4456D6B0F83F8D4349@DM5PR00MB0406.namprd00.prod.outlook.com>",
                                "bodyPreview": "",
                                "importance": "normal",
                                "parentFolderId": "AQMkAGNhZjFkYzQ3LTc2MDYtNGZiMS04ZGE3LTQ2MjUyZmRlMzA0NgAuAAAD7MLXbKjTeUeUiM62OAqxBAEA-PUmjl3OgEumTcnPoOXsegAAAgEBAAAAAA==",
                                "conversationId": "AAQkAGNhZjFkYzQ3LTc2MDYtNGZiMS04ZGE3LTQ2MjUyZmRlMzA0NgAQANQdjNmPALIE6YAJmOz4Qn4=",
                                "isRead": true,
                                "isDraft": true,
                                "webLink": "https://outlook.office365.com/owa/?ItemID=AQMkAGNhZjFkYzQ3LTc2MDYtNGZiMS04ZGE3LTQ2MjUyZmRlMzA0NgBGAAAD7MLXbKjTeUeUiM62OAqxBAcA%2FPUmjl3OgEumTcnPoOXsegAAAgEBAAAAAPz1Jo5dzoBLpk3Jz6Dl7HoAAAIJWgAAAA%3D%3D&exvsurl=1&viewmodel=ReadMessageItem",
                                "inferenceClassification": "focused"
                            }
                        }
                    ],
                    "total": 2,
                    "moreResultsAvailable": false
                }
            ]
        }
    ],
    "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#Collection(microsoft.graph.searchResponse)"
}

Bekannte Einschränkungen

  • Die benutzerdefinierte Sortierung wird in Verschachtelungsszenarien nicht unterstützt, alle Elemente werden nach Relevanz sortiert.
  • QueryTemplate wird nur für Dateielemente in einer überlappenden Abfrage unterstützt. Externe Elementergebnisse werden in der Antwort nicht herausgefiltert. Es wird nicht empfohlen, queryTemplate beim Überlappen von Anforderungen zu verwenden.
  • Das Reduzieren wird nicht unterstützt.
  • Die Änderung der Rechtschreibprüfung wird nicht unterstützt. Nur Rechtschreibvorschläge werden unterstützt.
  • Ergebnisvorlage wird nicht unterstützt.
  • Aggregationseinschränkungen treten auf, wenn das aggregierte Feld in mehreren SharePoint-Dateitypen (website, drive, driveItem, list, listItem) und Connectors vorhanden ist. Aggregationsergebnisse zeigen zwei Aggregationsbuckets mit demselben Namen an. Um die Einschränkung zu umgehen, benennen Sie eine von ihnen um.

Nächste Schritte