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

快速入门:查询事实Quickstart: Query for facts

如果查询针对诸如日期或可识别知识等事实,则响应可以包含 facts 答案。If the query is for a fact such as a date or identifiable knowledge, the response can contain facts answers. 事实答案包含从 Web 文档的段落中提取的相关结果。Fact answers contain relevant results extracted from paragraphs in web documents. 这些查询始终返回网页,且事实和/或实体依赖于查询。These queries always return webpages, and facts and/or entities are query-dependent.

valentines+2016、when+is+ramadan 等查询被视为与日期相关的查询。Queries such as valentines+2016, when+is+ramadan are considered date-related queries. 如果必应确定查询与日期相关,则响应包含 facts 答案。If Bing determines that the query is date-related, the response contains a facts answer.

下面的示例是日期相关的 facts 答案。The following example is a date-related facts answer.

查询:Query:

https://labsportalppe.azure-api.net/answerSearch/v7.0/search?q=valentines+2016

响应: subjectName 字段包含显示事实时可用作标签的用户查询的显示版本。Response: The subjectName field contains a display version of the user's query that you can use as a label when displaying the fact. 如果查询字符串是 valentines+2016,则必应可能将其更改为“Valentine's Day 2016”。If the query string is valentines+2016, Bing may change it Valentine's Day 2016. 说明字段包含事实。The description field contains the fact.

{
    "_type" : "SearchResponse",
    "queryContext" : {
        "originalQuery" : "valentines 2016"
    },
    "facts" : {
        "id" : "https:\/\/www.bingapis.com\/api\/v7\/#Facts",
        "value" : [{
            "description" : "Valentine's Day was on Sunday, February 14, 2016.",
            "subjectName" : "Valentine's Day 2016"
        }]
    },
    "rankingResponse" : {
        "mainline" : {
            "items" : [{
                "answerType" : "Facts",
                "value" : {
                    "id" : "https:\/\/www.bingapis.com\/api\/v7\/knowledge\/#Facts"
                }
            }]
        }
    }
}

查询“天空为何是蓝色的?”The query "Why is the sky blue?" 返回与知识相关的答案的示例。returns an example of a knowledge-related answer.

查询:Query:

https://api.labs.cognitive.microsoft.com/answerSearch/v7.0/search?q=why+is+the+sky+blue

响应: value/description 字段包含查询请求的知识或信息。Response: The value/description field contains the knowledge or information requested by the query.

  "facts": {
    "id": "https://www.bingapis.com/api/v7/#Facts",
    "contractualRules": [
      {
        "_type": "ContractualRules/LinkAttribution",
        "text": "en.wikipedia.org/wiki/Diffuse_sky_radiation",
        "url": "https://en.wikipedia.org/wiki/Diffuse_sky_radiation"
      },
      {
        "_type": "ContractualRules/LinkAttribution",
        "text": "spaceplace.nasa.gov/blue-sky/en/",
        "url": "https://spaceplace.nasa.gov/blue-sky/en/"
      }
    ],
    "attributions": [
      {
        "providerDisplayName": "en.wikipedia.org/wiki/Diffuse_sky_radiation",
        "seeMoreUrl": "https://en.wikipedia.org/wiki/Diffuse_sky_radiation"
      },
      {
        "providerDisplayName": "spaceplace.nasa.gov/blue-sky/en/",
        "seeMoreUrl": "https://spaceplace.nasa.gov/blue-sky/en/"
      }
    ],
    "value": [
      {
        "image": {
          "webSearchUrl": "https://www.bing.com/images/search?view=detailv2&FORM=OIIRPO&q=&id=B632272C4E934D7F0B18790300B2DE34E7676C7A&simid=608045681196075791&iss=eqna",
          "name": "Why is the sky blue in the sky?",
          "thumbnailUrl": "https://www.bing.com/th?id=ODE.858093005&w=140&h=140&c=8&rs=1&qlt=100&pid=3.1",
          "isFamilyFriendly": true
        },
        "description": "When sunlight reaches Earth's atmosphere, it is scattered in all directions by all the gases and particles in the air. Blue is scattered by air molecules more than other colors because it travels as shorter, smaller waves. This is why we see a blue sky most of the time.\n\nCloser to the horizon, the sky fades to a lighter blue or white. The sunlight reaching us from low in the sky has passed through even more air than the sunlight reaching us from overhead. As the sunlight has passed through all this air, the air molecules have scattered and rescattered the blue light many times in many directions. Also, the surface of Earth has reflected and scattered the light. All this scattering mixes the colors together again so we see more white and less blue.",
        "subjectName": "Why is the sky blue in the sky?",
        "primaryData": [
          "The atmosphere scatters more blue light"
        ]
      }
    ]
  },

表格数据Tabular data

在某些情况下,事实可作为 _type: StructuredValue/TabularData 返回。In some cases, facts can be returned as _type: StructuredValue/TabularData. 以下查询获取咖啡和茶对比信息的表格数据。The following query gets tabular data with contrasting information about coffee and tea.

https://labsportalppe.azure-api.net/answerSearch/v7.0/search?q=coffee+vs+tea&mkt=en-us

facts 结果包含以下行和单元格:The facts results include the following rows and cells:

    "value": [
      {
        "subjectName": "Coffee vs. Tea",
        "richCaption": {
          "_type": "StructuredValue/TabularData",
          "header": [
            "",
            "Coffee",
            "Tea"
          ],
          "rows": [
            {
              "cells": [
                {
                  "text": "Part of plant used"
                },
                {
                  "text": "Bean"
                },
                {
                  "text": "Leaf"
                }
              ]
            },
            {
              "cells": [
                {
                  "text": "Caffeine Content"
                },
                {
                  "text": "80-185 mg per 8 ounce cup depending upon the brew and the..."
                },
                {
                  "text": "15 - 70 mg per cup"
                }
              ]
            },
            {
              "cells": [
                {
                  "text": "Types of Consumption"
                },
                {
                  "text": "Drip Coffee"
                },
                {
                  "text": "White Tea"
                }
              ]
            },
            {
              "cells": [
                {
                  "text": "Additions"
                },
                {
                  "text": "Sugar"
                },
                {
                  "text": "Milk"
                }
              ]
            }
          ],
          "seeMoreUrl": {
            "text": "8 more rows",
            "url": "https://www.diffen.com/difference/Coffee_vs_Tea"
          }
        }
      }
    ]
  },

后续步骤Next steps