您现在访问的是微软AZURE全球版技术文档网站,若需要访问由世纪互联运营的MICROSOFT AZURE中国区技术文档网站,请访问 https://docs.azure.cn.

什么是必应自动建议?What is Bing Autosuggest?

如果应用程序向任何必应搜索 API 发送查询,可以使用必应自动建议 API 来改进用户的搜索体验。If your application sends queries to any of the Bing Search APIs, you can use the Bing Autosuggest API to improve your users' search experience. 必应自动建议 API 根据搜索框中的部分查询字符串返回建议查询的列表。The Bing Autosuggest API returns a list of suggested queries based on the partial query string in the search box. 在搜索框中输入字符时,可以在下拉列表中显示建议。As characters are entered into the search box, you can display suggestions in a drop-down list.

必应自动建议 API 功能Bing Autosuggest API features

FeatureFeature 说明Description
实时建议搜索词Suggest search terms in real-time 通过在你键入时使用自动建议 API 显示建议的搜索词来改善应用体验。Improve your app experience by using the Autosuggest API to display suggested search terms as they're typed.

工作流Workflow

必应自动建议 API 是一项 RESTful Web 服务,可以轻松地通过任何编程语言调用,只要该语言能够发出 HTTP 请求和分析 JSON 即可。The Bing Autosuggest API is a RESTful web service, easy to call from any programming language that can make HTTP requests and parse JSON.

  1. 创建可以访问必应搜索 API 的认知服务 API 帐户Create a Cognitive Services API account with access to the Bing Search APIs. 如果没有 Azure 订阅,可以免费创建一个帐户If you don't have an Azure subscription, you can create an account for free.
  2. 每次用户在应用程序的搜索框中键入新字符时,都会向此 API 发送请求。Send a request to this API each time a user types a new character in your application's search box.
  3. 通过分析返回的 JSON 消息处理 API 响应。Process the API response by parsing the returned JSON message.

通常,每次用户在应用程序的搜索框中键入新字符时,你都会调用此 API。Typically, you'd call this API each time the user types a new character in your application's search box. 输入更多字符时,API 将返回更相关的建议搜索查询。As more characters are entered, the API will return more relevant suggested search queries. 例如,API 可能为单个 s 返回的建议可能不如为 sail 返回的建议相关。For example, the suggestions the API might return for a single s are likely to be less relevant than ones for sail.

下面的示例显示了一个下拉搜索框,其中包含 Bing 自动建议 API 提供的建议查询词。The following example shows a drop-down search box with suggested query terms from the Bing Autosuggest API.

自动建议下拉搜索框列表

当用户从下拉列表中选择建议时,你可以使用它开始通过必应搜索 API 之一进行搜索,或者直接转到必应搜索结果页。When a user selects a suggestion from the drop-down list, you can use it to begin searching with one of the Bing Search APIs, or directly go to the Bing search results page.

后续步骤Next steps

若要快速了解如何使用第一个请求,请参阅创建第一个查询To get started quickly with your first request, see Making Your First Query.

使自己熟悉必应自动建议 API v7 参考文档。Familiarize yourself with the Bing Autosuggest API v7 reference. 此参考文档包含可以用来请求建议查询词的终结点、标头和查询参数的列表,以及响应对象的定义。The reference contains the list of endpoints, headers, and query parameters that you'd use to request suggested query terms, and the definitions of the response objects.

请访问必应搜索 API 中心页,浏览其他可用的 API。Visit the Bing Search API hub page to explore the other available APIs.

了解如何使用必应 Web 搜索 API 搜索 Web,并浏览其他必应搜索 APILearn how to search the web by using the Bing Web Search API, and explore the otherBing Search APIs.

确保阅读必应使用和显示要求,以免违反关于搜索结果使用要求的任何规则。Be sure to read Bing Use and Display Requirements so you don't break any of the rules about using the search results.