Inicio rápido: Consulta de datosQuickstart: Query for facts

Si la consulta es para un dato como una fecha o una información identificable, la respuesta puede contener facts respuestas.If the query is for a fact such as a date or identifiable knowledge, the response can contain facts answers. Las respuestas de datos contienen resultados apropiados extraídos de párrafos de documentos web.Fact answers contain relevant results extracted from paragraphs in web documents. Estas consultas siempre devuelven páginas web y tanto los datos como las entidades, o cualquiera de ellos, dependen de las consultas.These queries always return webpages, and facts and/or entities are query-dependent.

Consultas como san valentín+2016 o cuándo+es+ramadán se consideran consultas relacionadas con fechas.Queries such as valentines+2016, when+is+ramadan are considered date-related queries. Si Bing determina que la consulta está relacionado con fechas, la respuesta contiene una respuesta facts.If Bing determines that the query is date-related, the response contains a facts answer.

El ejemplo siguiente es una respuesta facts relacionada con fechas.The following example is a date-related facts answer.

Consulta:Query:

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

Respuesta: el campo subjectName contiene una versión para mostrar de la consulta del usuario que se puede usar como etiqueta al mostrar el dato.Response: The subjectName field contains a display version of the user's query that you can use as a label when displaying the fact. Si la cadena de consulta es san valentín+2016, Bing puede cambiarla a día de San Valentín de 2016.If the query string is valentines+2016, Bing may change it Valentine's Day 2016. El campo de descripción contiene los datos.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"
                }
            }]
        }
    }
}

La consulta "¿Por qué es el cielo azul?"The query "Why is the sky blue?" devuelve un ejemplo de una respuesta relacionada con el conocimiento.returns an example of a knowledge-related answer.

Consulta:Query:

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

Respuesta: el campo value/description contiene el conocimiento o la información solicitados por la consulta.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"
        ]
      }
    ]
  },

Datos tabularesTabular data

En algunos casos, los datos se puede devolver como _type: StructuredValue/TabularData.In some cases, facts can be returned as _type: StructuredValue/TabularData. La consulta siguiente obtiene datos tabulares con información de contraste acerca de café y té.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

Los resultados de facts incluyen las siguientes filas y celdas: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"
          }
        }
      }
    ]
  },

Pasos siguientesNext steps