Monday, September 16, 2013

Google search engine response(JSON) structure


  This document is intended for developers who want to write applications that can interact with the JSON/Atom Custom Search API. We will analyze the structure of the response that we received after an http GET request to google search engine.

Response data:
{
 "kind": "customsearch#search",
 "url": {
  "type": "application/json",
  "template": "https://www.googleapis.com/customsearch/v1?q={searchTerms}&num={.},
 "queries": {
  "nextPage": [
   {
    "title": "Google Custom Search - stars",
    "totalResults": "309000",
    "searchTerms": "stars",
    "count": 10,
    "startIndex": 11,
    "inputEncoding": "utf8",
    "outputEncoding": "utf8",
    "safe": "off",
    "cx": "002551901808508802477:39t74qehyw0"
   }
  ],
  "request": [
   {
    "title": "Google Custom Search - stars",
    "totalResults": "309000",
    "searchTerms": "stars",
    "count": 10,
    "startIndex": 1,
    "inputEncoding": "utf8",
    "outputEncoding": "utf8",
    "safe": "off",
    "cx": "002551901808508802477:39t74qehyw0"
   }
  ]
 },
 "context": {
  "title": "Customized.Searching"
 },
 "searchInformation": {
  "searchTime": 0.29926,
  "formattedSearchTime": "0.30",
  "totalResults": "309000",
  "formattedTotalResults": "309,000"
 },
 "items": [
  {
   "kind": "customsearch#result",
   "title": "Formation of the First Stars",
   "htmlTitle": "Formation of the First \u003cb\u003eStars\u003c/b\u003e",
   "link": "http://arxiv.org/abs/1305.5178",
   "displayLink": "arxiv.org",
   "snippet": "May 22, 2013 ... Abstract: Understanding the formation of the...", 
   "htmlSnippet": "May 22, 2013 \u003cb\u003e...Abstract: Unde...", 
   "cacheId": "CbjG-txlc30J",
   "formattedUrl": "arxiv.org/abs/1305.5178",
   "htmlFormattedUrl": "arxiv.org/abs/1305.5178",
   "pagemap": {
    "metatags": [
     {
      "citation_title": "Formation of the First Stars",
      "citation_author": "Bromm, Volker",
      "citation_date": "2013/05/22",
      "citation_online_date": "2013/05/22",
      "citation_pdf_url": "http://arxiv.org/pdf/1305.5178",
      "citation_arxiv_id": "1305.5178"
     }
    ]
   }
  },
  .
  .
  .
  .
  {
   "kind": "customsearch#result",
   "title": "[1309.0096] Quark deconfinement transition in neutron stars...", 
        "htmlTitle": "[1309.0096] Quark deconfinement transition in neutron 0096", 
        "displayLink": "arxiv.org",
"snippet": "Aug 31, 2013 ... Abstract: A phaseof stronginteracting marwi...", 
        "htmlSnippet": "Aug 31, 2013 \u003cb\u003e...\u003c/b\u003e Abstract: Aphase", 
        "cacheId": "_eXZTeanAq8J",
   "formattedUrl": "arxiv.org/abs/1309.0096",
   "htmlFormattedUrl": "arxiv.org/abs/1309.0096",
   "pagemap": {
    "metatags": [
     {
      "citation_title": "Quark deconfinement transition in neutr", 
      "citation_author": "Logoteta, Domenico",
      "citation_date": "2013/08/31",
      "citation_online_date": "2013/08/31",
      "citation_pdf_url": "http://arxiv.org/pdf/1309.0096",
      "citation_arxiv_id": "1309.0096"
     }
    ]
   }
  }
 ]
}
As shown in the sample output above, the response data includes three main classes of properties:

  • Search metadata 
  • Custom search engine metadata
  • Search results
  The main classes of data are described below:

 Search metadata 

 The search metadata includes the url property, which has information about the OpenSearch template used for the results returned in this request. It also includes a queries property, which is an array of objects describing the characteristics of possible searches. The name of each object in the array is either the name of an OpenSearch query role or one of the two custom roles defined by this API: previousPage and nextPage .


 Each query role object is itself an array, though usually the array contains a single element. Possible query role objects include:

request: Metadata describing the query for the current set of results. This role is always present in the response. It is always an array with just one element.
nextPage: Metadata describing the query to use for the next page of results. This role is not present if the current results are the last page. Note: This API returns up to the first 100 results only. When present, it is always a array with just one element.
previousPage: Metadata describing the query to use for the previous page of results. Not present if the current results are the first page. When present, it is always a array with just one element.

 Note: The totalResults property in the objects above identifies the estimated total number of results for the search, which may not be accurate.

 Custom search engine metadata 

 The context property has metadata describing the search engine that performed the search query. It includes the name of the search engine, and any facet objects it provides for refining a search.

 Search results 

 The items array contains the actual search results. The search results include the URL, title and text snippets that describe the result. In addition, they can contain pagemap information, if applicable. If the search results include a promotions property, it contains a set of promotions.





No comments:

Post a Comment