为 Microsoft 365 多地理位置配置搜索Configure Search for Microsoft 365 Multi-Geo

在多地理位置环境中,每个地理位置都有自己的搜索索引和搜索中心。In a multi-geo environment, each geo location has its own search index and Search Center. 在用户搜索时,查询会扇出以覆盖所有索引,并合并返回的结果。When a user searches, the query is fanned out to all the indexes, and the returned results are merged.

例如,位于一个地理位置的用户可以搜索在另一个地理位置中存储的内容,也可以搜索只限不同地理位置的 SharePoint 网站内容。For example, a user in one geo location can search for content stored in another geo location, or for content on a SharePoint site that's restricted to a different geo location. 如果用户有权访问此内容,便会看到搜索结果。If the user has access to this content, search will show the result.

在多地理位置环境中可以运行哪些搜索客户端?Which search clients work in a multi-geo environment?

这些客户端可以返回来自所有地理位置的结果:These clients can return results from all geo locations:

  • OneDrive for BusinessOneDrive for Business
  • DelveDelve
  • SharePoint 主页The SharePoint home page
  • 搜索中心The Search Center
  • 使用 SharePoint 搜索 API 的自定义搜索应用程序Custom search applications that use the SharePoint Search API

OneDrive for BusinessOneDrive for Business

多地理位置环境一旦设置,在 OneDrive 中搜索的用户即可获得来自所有地理位置的结果。As soon as the multi-geo environment has been set up, users that search in OneDrive get results from all geo locations.

DelveDelve

多地理位置环境一旦设置,在 Delve 中搜索的用户即可获得来自所有地理位置的结果。As soon as the multi-geo environment has been set up, users that search in Delve get results from all geo locations.

Delve 源和个人资料卡仅显示存储在中心位置的文件的预览。The Delve feed and the profile card only show previews of files that are stored in the central location. 对于存储在附属位置的文件,则会显示文件类型的图标。For files that are stored in satellite locations, the icon for the file type is shown instead.

SharePoint 主页The SharePoint home page

多地理位置环境一旦设置,用户即可在其 SharePoint 主页上看到来自多地理位置的资讯、最近访问和关注的网站。如果他们使用 SharePoint 主页上的搜索框,则他们将获得来自多地理位置的合并结果。As soon as the multi-geo environment has been set up, users will see news, recent and followed sites from multiple geo locations on their SharePoint home page. If they use the search box on the SharePoint home page, they'll get merged results from multiple geo locations.

搜索中心The Search Center

多地理位置环境设置后,每个搜索中心将继续仅显示来自其各自地理位置的结果。管理员必须更改每个搜索中心的设置,以获取来自所有地理位置的结果。之后,在搜索中心搜索的用户将获得来自所有地理位置的结果。After the multi-geo environment has been set up, each Search Center continues to only show results from their own geo location. Admins must change the settings of each Search Center to get results from all geo locations. Afterwards, users that search in the Search Center get results from all geo locations.

自定义搜索应用程序Custom search applications

同样,自定义搜索应用程序使用现有 SharePoint Search REST API 与搜索索引进行交互。若要获取来自所有(或部分)地理位置的结果,应用程序必须在请求中调用 API 并包含新的多地理位置查询参数。这将触发对所有地理位置的查询扇出。As usual, custom search applications interact with the search indexes by using the existing SharePoint Search REST APIs. To get results from all, or some geo locations, the application must call the API and include the new Multi-Geo query parameters in the request. This triggers a fan out of the query to all geo locations.

在多地理位置环境中搜索有什么不同之处?What's different about search in a multi-geo environment?

你所熟悉的某些搜索功能在多地理位置环境中的工作方式可能有所不同。Some search features you might be familiar with, work differently in a multi-geo environment.

功能Feature 工作原理How it works 解决方法Workaround
升级的结果Promoted results 您可以在不同级别创建具有升级的结果的查询规则:整个租户、网站集或网站。You can create query rules with promoted results at different levels: for the whole tenant, for a site collection, or for a site. 在多地理位置环境中的租户级别定义升级的结果,以便将结果升级到所有地理位置中的搜索中心。In a multi-geo environment, define promoted results at the tenant level to promote the results to the Search Centers in all geo locations. 如果只想升级位于站点集或站点的搜索中心中的结果,请在站点集或站点级别定义升级的结果。If you only want to promote results in the Search Center that's in the geo location of the site collection or site, define the promoted results at the site collection or site level. 不会升级位于其他地理位置的结果。These results are not promoted in other geo locations. 如果不需要对每个地理位置使用不同的升级结果(例如,在出差时使用不同的规则),我们建议在租户级别定义升级的结果。If you don't need different promoted results per geo location, for example different rules for traveling, we recommend defining promoted results at the tenant level.
搜索精简Search refiners 搜索将返回来自租户的所有地理位置的精简内容,然后对其进行聚合。聚合是最佳做法,意味着精简计数可能并非 100% 准确。对于大部分搜索驱动的方案,此准确度已足够。 Search returns refiners from all the geo locations of a tenant and then aggregates them. The aggregation is a best effort, meaning that the refiner counts might not be 100% accurate. For most search-driven scenarios, this accuracy is sufficient. 对于依赖于精简完整度的搜索驱动的应用程序,请单独查询每个地理位置。For search-driven applications that depend on refiner completeness, query each geo location independently.
多地理位置搜索不支持数值精简的动态存储桶。Multi-geo search doesn't support dynamic bucketing for numerical refiners. 数字精简条件使用"Discretize" 参数。Use the "Discretize" parameter for numerical refiners.
文档 IDDocument IDs 如果正在开发依赖于文档 ID 的搜索驱动的应用程序,请注意,多地理位置环境中的文档 ID 对所有地理位置来说并不是唯一的,它们只对每个地理位置来说是唯一的。If you're developing a search-driven application that depends on document IDs, note that document IDs in a multi-geo environment aren't unique across geo locations, they are unique per geo location. 我们添加了用于标识地理位置的列。We've added a column that identifies the geo location. 使用此列来实现唯一性。Use this column to achieve uniqueness. 此列名为"GeoLocationSource"。This column is named "GeoLocationSource".
结果数Number of results 搜索结果页将显示来自地理位置的组合结果,但该页显示的结果不能超过 500 个。The search results page shows combined results from the geo locations, but it's not possible to page beyond 500 results.
混合搜索Hybrid search 在具有云混合搜索的混合 SharePoint 环境中,本地内容将添加到中心位置的 Microsoft 365 索引。In a hybrid SharePoint environment with cloud hybrid search, on-premises content is added to the Microsoft 365 index of the central location.

在多地理位置环境中不支持的搜索有哪些?What's not supported for search in a multi-geo environment?

你所熟悉的某些搜索功能在多地理位置环境中可能不受支持。Some of the search features you might be familiar with, aren't supported in a multi-geo environment.

搜索功能Search feature 注意Note
仅应用身份验证App-only authentication 在多地理位置搜索中不支持仅应用身份验证(来自服务的特权访问)。App-only authentication (privileged access from services) isn't supported in multi-geo search.
来宾用户Guest users 来宾用户仅获得其搜索的地理位置中的结果。Guest users only get results from the geo location that they're searching from.

如何在多地理位置环境中进行搜索?How does search work in a multi-geo environment?

所有搜索客户端均使用现有 SharePoint Search REST API 与搜索索引进行交互。All the search clients use the existing SharePoint Search REST APIs to interact with the search indexes.

显示 SharePoint 搜索 REST API 如何与搜索索引交互的关系图

  1. 搜索客户端使用查询属性 EnableMultiGeoSearch= true 来调用搜索 REST 终结点。A search client calls the Search REST endpoint with the query property EnableMultiGeoSearch= true.
  2. 查询将被发送到租户中的所有地理位置。The query is sent to all geo locations in the tenant.
  3. 将对来自每个地理位置的搜索结果进行合并和排名。Search results from each geo location are merged and ranked.
  4. 客户端将获得统一的搜索结果。The client gets unified search results.

请注意,在收到来自所有地理位置的结果之前,我们不会合并搜索结果。Notice that we don't merge the search results until we've received results from all the geo locations. 这意味着,与仅包含一个地理位置的环境中的搜索相比,多地理位置搜索会有额外的延迟。This means that multi-geo searches have additional latency compared to searches in an environment with only one geo location.

获取搜索中心以显示来自所有地理位置的结果Get a Search Center to show results from all geo locations

每个搜索中心具有多个类别,必须单独设置每个类别。Each Search Center has several verticals and you have to set up each vertical individually.

  1. 请确保执行这些步骤所使用的帐户具有编辑搜索结果页和搜索结果 Web 部件的权限。Ensure that you perform these steps with an account that has permission to edit the search results page and the Search Result Web Part.

  2. 导航到搜索结果页(请参阅搜索结果页的列表Navigate to the search results page (see the list of search results pages)

  3. 选择要设置的类别,单击右上角的 “设置” 齿轮图标,然后单击 “编辑页面”。搜索结果页将在编辑模式下打开。Select the vertical to set up, click Settings gear icon in the upper, right corner, and then click Edit Page. The search results page opens in Edit mode.

    在"设置"中编辑页面选择

  4. 在搜索结果 Web 部件中,将鼠标指针移动到 Web 部件的右上角,单击箭头,然后单击菜单上的“编辑 Web 部件 ”。In the Search Results Web Part, move the pointer to the upper, right corner of the web part, click the arrow, and then click Edit Web Part on the menu. 搜索结果 Web 部件工具窗格在页面右上角的功能区下方打开。The Search Results Web Part tool pane opens under the ribbon in the top right of the page.

    编辑Web 部件选择

  5. 在 Web 部件工具窗格中的 “设置” 部分,在 “结果控制设置” 下,选择 “显示多地理位置结果”,获取搜索结果 Web 部件,以显示来自所有地理位置的结果。In the Web Part tool pane, in the Settings section, under Results control settings, select Show Multi-Geo results to get the Search Results Web Part to show results from all geo locations.

  6. 单击 “确定”,以保存更改并关闭 Web 部件工具窗格。Click OK to save your change and close the Web Part tool pane.

  7. 单击主菜单 “页面”选项卡上的“签入”,查看对搜索结果 Web 部件所做的更改。Check your changes to the Search Results Web Part by clicking Check-In on the Page tab of the main menu.

  8. 使用页面顶部的注释中提供的链接来发布更改。Publish the changes by using the link provided in the note at the top of the page.

获取自定义搜索应用程序,以显示来自所有(或部分)地理位置的结果Get custom search applications to show results from all or some geo locations

自定义搜索应用程序通过使用对 SharePoint 搜索 REST API 的请求指定查询参数,从所有或部分地理位置获取结果。Custom search applications get results from all, or some, geo locations by specifying query parameters with the request to the SharePoint Search REST API. 根据查询参数,查询会扇出到所有地理位置或某些地理位置。Depending on the query parameters, the query is fanned out to all geo locations, or to some geo locations. 例如,如果只需要查询地理位置的子集以查找相关信息,你可以仅控制扇出到这些地理位置。For example, if you only need to query a subset of geo locations to find relevant information, you can control the fan out to only these. 如果请求成功,SharePoint 搜索 REST API 将返回响应数据。If the request succeeds, the SharePoint Search REST API returns response data.

要求Requirement

对于每个地理位置,必须确保组织中的所有用户都已授予根网站(例如 contoso APAC.sharepoint.com/ and contoso EU.sharepoint.com/)的 读取 权限级别。了解权限For each geo location, you must ensure that all users in the organization have been granted the Read permission level for the root website (for example contoso APAC.sharepoint.com/ and contoso EU.sharepoint.com/). Learn about permissions.

查询参数Query parameters

EnableMultiGeoSearch - 此布尔值指定是否应将查询扇出到多地理位置租户的其他地理位置的索引。EnableMultiGeoSearch - This is a Boolean value that specifies whether the query shall be fanned out to the indexes of other geo locations of the multi-geo tenant. 将其设置为 true 以扇出查询;设置为 false 则不扇出查询。Set it to true to fan out the query; false to not fan out the query. 如果不包含此参数,则默认值为 false(除非针对使用企业搜索中心模板的网站执行 REST API 调用,在这种情况下,默认值为 true)。If you don't include this parameter, the default value is false, except when making a REST API call against a site which uses the Enterprise Search Center template, in this case the default value is true. 如果在非多地理位置环境中使用该参数,则会忽略该参数。If you use the parameter in an environment that isn't multi-geo, the parameter is ignored.

ClientType - 此参数为字符串。ClientType - This is a string. 输入每个搜索应用程序的唯一客户端名称。Enter a unique client name for each search application. 如果不包括此参数,则不会将查询扇出到其他地理位置。If you don't include this parameter, the query is not fanned out to other geo locations.

MultiGeoSearchConfiguration - 这是一个可选列表,其中包含多地理位置租户中的一些地理位置,当 EnableMultiGeoSearchtrue 时,会将查询扇出到这些地理位置。MultiGeoSearchConfiguration - This is an optional list of which geo locations in the multi-geo tenant to fan the query out to when EnableMultiGeoSearch is true. 如果不包括此参数,或将其保留为空白,则会将查询扇出到所有地理位置。If you don't include this parameter, or leave it blank, the query is fanned out to all geo locations. 对于每个地理位置,请以 JSON 格式输入以下各项:For each geo location, enter the following items, in JSON format:

项目Item 说明Description
DataLocationDataLocation 地理位置,例如 NAM。The geo location, for example NAM.
终结点EndPoint 要连接到的终结点,例如 https://contoso.sharepoint.comThe endpoint to connect to, for example https://contoso.sharepoint.com
SourceIdSourceId 结果源的 GUID,例如 B81EAB55-3140-4312-B0F4-9459D1B4FFEE。The GUID of the result source, for example B81EAB55-3140-4312-B0F4-9459D1B4FFEE.

如果省略 DataLocation 或终结点,或如果 DataLocation 是重复的,则请求将会失败。可以使用 Microsoft Graph 获取有关租户地理位置终结点的信息If you omit DataLocation or EndPoint, or if a DataLocation is duplicated, the request fails. You can get information about the endpoint of a tenant's geo locations by using Microsoft Graph.

响应数据Response data

MultiGeoSearchStatus - 这是 SharePoint Search API 响应请求返回的属性。该属性的值是一个字符串,提供有关 SharePoint Search API 所返回结果的以下信息:MultiGeoSearchStatus – This is a property that the SharePoint Search API returns in response to a request. The value of the property is a string and gives the following information about the results that the SharePoint Search API returns:

Value 说明Description
完整Full 来自所有地理位置的完整结果。Full results from all the geo locations.
部分Partial 来自一个或多个地理位置的部分结果。由于暂时性错误,该结果不完整。Partial results from one or more geo locations. The results are incomplete due to a transient error.

使用 REST 服务查询Query using the REST service

使用 GET 请求,指定 URL 中的查询参数。使用 POST 请求,在正文中以 JavaScript 对象表示法 (JSON) 格式传递查询参数。With a GET request, you specify the query parameters in the URL. With a POST request, you pass the query parameters in the body in JavaScript Object Notation (JSON) format.

请求标头Request headers

名称Name Value
Content-TypeContent-Type application/json;odata=verboseapplication/json;odata=verbose

扇出到 所有 地理位置的示例 GET 请求Sample GET request that's fanned out to all geo locations

https:// <tenant> / _ api/search/query?querytext='sharepoint'&Properties='EnableMultiGeoSearch:true'&ClientType='my _ client _ id'https:// <tenant>/_api/search/query?querytext='sharepoint'&Properties='EnableMultiGeoSearch:true'&ClientType='my_client_id'

扇出部分地理位置的示例 GET 请求Sample GET request to fan out to some geo locations

https:// <tenant> / _ api/search/query?querytext='site'&ClientType='my_client_id'&Properties='EnableMultiGeoSearch:true, MultiGeoSearchConfiguration:[{DataLocation \ :"NAM" \ ,Endpoint \ :"https \ ://contosoNAM.sharepoint.com" \ ,SourceId \ :"B81EAB55-3140-4312-B0F4-9459D1B4FFEE"} \ ,{DataLocation \ :"CAN" \ ,Endpoint \ :"https \ ://contosoCAN.sharepoint-df.com"}]'https:// <tenant>/_api/search/query?querytext='site'&ClientType='my_client_id'&Properties='EnableMultiGeoSearch:true, MultiGeoSearchConfiguration:[{DataLocation\:"NAM"\,Endpoint\:"https\://contosoNAM.sharepoint.com"\,SourceId\:"B81EAB55-3140-4312-B0F4-9459D1B4FFEE"}\,{DataLocation\:"CAN"\,Endpoint\:"https\://contosoCAN.sharepoint-df.com"}]'

备注

MultiGeoSearchConfiguration 属性的地理位置列表中的逗号和冒号前面带有 反斜杠 字符。Commas and colons in the list of geo locations for the MultiGeoSearchConfiguration property are preceded by the backslash character. 这是因为 GET 请求使用冒号分隔属性,并使用逗号分隔属性的参数。This is because GET requests use colons to separate properties and commas to separate arguments of properties. 如果不使用反斜杠作为转义字符,则 MultiGeoSearchConfiguration 属性会被错误解读。Without the backslash as an escape character, the MultiGeoSearchConfiguration property is interpreted wrongly.

扇出到 所有 地理位置的示例 POST 请求Sample POST request that's fanned out to all geo locations

    {
    "request": {
            "__metadata": {
            "type": "Microsoft.Office.Server.Search.REST.SearchRequest"
        },
        "Querytext": "sharepoint",
        "Properties": {
            "results": [
                {
                    "Name": "EnableMultiGeoSearch",
                    "Value": {
                        "QueryPropertyValueTypeIndex": 3,
                        "BoolVal": true
                    }
                }
            ]
        },
        "ClientType": "my_client_id"
        }
    }

扇出到 部分 地理位置的示例 POST 请求Sample POST request that's fanned out to some geo locations

    {
        "request": {
            "Querytext": "SharePoint",
            "ClientType": "my_client_id",
            "Properties": {
                "results": [
                    {
                        "Name": "EnableMultiGeoSearch",
                        "Value": {
                            "QueryPropertyValueTypeIndex": 3,
                            "BoolVal": true
                        }
                    },
                    {
                        "Name": "MultiGeoSearchConfiguration",
                        "Value": {
                        "StrVal": "[{\"DataLocation\":\"NAM\",\"Endpoint\":\"https://contoso.sharepoint.com\",\"SourceId\":\"B81EAB55-3140-4312-B0F4-9459D1B4FFEE\"},{\"DataLocation\":\"CAN\",\"Endpoint\":\"https://contosoCAN.sharepoint.com\"}]",
                            "QueryPropertyValueTypeIndex": 1
                        }
                    }
                ]
            }
        }
    }

使用 CSOM 查询Query using CSOM

以下是扇出到 所有 地理位置的示例 CSOM 请求:Here's a sample CSOM query that's fanned out to all geo locations:

var keywordQuery = new KeywordQuery(ctx);
keywordQuery.QueryText = query.SearchQueryText;
keywordQuery.ClientType = <enter a string here>;
keywordQuery["EnableMultiGeoSearch"] = true;