Share via


Anatomy of a results set

The results returned for a request differ from SourceType to SourceType, but in every case they include a header and a results body. The document element is always SearchResponse, with a Query child element that contains the query used to produce the results. These two elements make up the header. You can see this header in Figure 1, which shows partial results that the request in the previous section might generate.

<?xml version="1.0" encoding="utf-8" ?> 
  <?pageview_candidate ?> 
- <SearchResponse xmlns="http://schemas.microsoft.com/LiveSearch/2008/04/XML/element" Version="2.0">
- <Query>
  <SearchTerms>sushi</SearchTerms> 
  </Query>
- <web:Web xmlns:web="http://schemas.microsoft.com/LiveSearch/2008/04/XML/web">
  <web:Total>12400000</web:Total> 
  <web:Offset>0</web:Offset> 
- <web:Results>
- <web:WebResult>
  <web:Title>Sushi - Wikipedia, the free encyclopedia</web:Title> 
  <web:Description>In Japanese cuisine, sushi (寿司, 鮨, 鮓, sushi?) is vinegared rice, usually topped with other ingredients, including fish, various meats, and vegetables.</web:Description> 
  <web:Url>http://en.wikipedia.org/wiki/Sushi</web:Url> 
  <web:DisplayUrl>http://en.wikipedia.org/wiki/Sushi</web:DisplayUrl> 
  <web:DateTime>2009-01-11T19:22:53Z</web:DateTime> 
  <web:Rank>2.905846</web:Rank> 
  </web:WebResult>
- <web:WebResult>
  <web:Title>Sushi Guide - Eatsushi.com</web:Title> 
  <web:Description>Eatsushi.com... The best, most complete sushi website. With an extensive sushi database, sushi products and preparation aids, and even streaming video that will show you how sushi ...</web:Description> 
  <web:Url>http://www.eatsushi.com/</web:Url> 
  <web:DisplayUrl>http://www.eatsushi.com/</web:DisplayUrl> 
  <web:DateTime>2009-01-15T09:16:51Z</web:DateTime> 
  <web:Rank>1.042794</web:Rank> 
  </web:WebResult>
- <web:WebResult>
  <web:Title>Sushi Sushi, Inc.</web:Title>

Figure 1: XML Results

The results body follows the header. If only one SourceType is used, there will be one additional child element of SearchResponse after the Query element, but there can be more than one if multiple SourceTypes are used. Each SourceType has its own XML namespace URI (and, therefore, its own schema), but all SourceTypes share a common structure. In Figure 1, because the request was to the Web SourceType, the body is an element named Web from the http://schemas.microsoft.com/LiveSearch/2008/04/XML/web namespace.

Working with Total, Offset, and Count

The Web element subordinates two elements that are qualified by the web namespace, but are common to all SourceTypes: Total and Offset. The Total element contains the estimatednumber of results for the request in that particular SourceType, while Offset indicates how far into the result set you are currently processing.

Note

Depending on how popular a query is, the estimated number of results could be very different from the real number. Do not rely on this number for critical computation.

Each SourceType has a default number of results, which can be modified using the optional Count parameter. You can change Offset using the optional Offset parameter. Since you might be using multiple SourceTypes, both Count and Offset need to be qualified by the SourceType.

For example, if you wanted to ask for 40 results at a time from the Web SourceType, you would pass web.count=40 as part of the query string. If you wanted to get the next 40 results after getting the first results, you would pass web.offset=41. The full URI would be http://api.search.live.net/xml.aspx?Appid=<AppID>&query=sushi&sources=web&web.count=40&web.offset=41. Figure 2 display partial results that this request might return.

<?xml version="1.0" encoding="utf-8" ?> 
  <?pageview_candidate ?> 
- <SearchResponse xmlns="http://schemas.microsoft.com/LiveSearch/2008/04/XML/element" Version="2.0">
- <Query>
  <SearchTerms>sushi</SearchTerms> 
  </Query>
- <web:Web xmlns:web="http://schemas.microsoft.com/LiveSearch/2008/04/XML/web">
  <web:Total>12400000</web:Total> 
  <web:Offset>41</web:Offset> 
- <web:Results>
- <web:WebResult>
  <web:Title>SUSHISAMBA</web:Title> 
  <web:Description>specialty cocktails</web:Description> 
  <web:Url>http://www.sushisamba.com/</web:Url> 
  <web:DisplayUrl>http://www.sushisamba.com/</web:DisplayUrl> 
  <web:DateTime>2009-01-20T20:59:35Z</web:DateTime> 
  <web:Rank>0.072175</web:Rank> 
  </web:WebResult>
- <web:WebResult>
  <web:Title>Kura Sushi</web:Title> 
  <web:Description>What's New! - We have produced a video about our company that will be aired nationally in “Let’s Talk Franchise” Program. - We have hired Key individual for our Main ...</web:Description> 
  <web:Url>http://www.kurasushi.com/</web:Url> 
  <web:DisplayUrl>http://www.kurasushi.com/</web:DisplayUrl> 
  <web:DateTime>2008-01-22T03:08:02Z</web:DateTime> 
  <web:Rank>0.068730</web:Rank> 
  </web:WebResult>
- <web:WebResult>
  <web:Title>Sushi Guide</web:Title> 
  <web:Description>ITADAKIMASU! Sushi is the well-balanced Japanese delicacy that most of the world has come to know and love. Click below to learn more.</web:Description> 
  <web:Url>http://www.novospace.com/channels/sushi/</web:Url> 
  <web:DisplayUrl>http://www.novospace.com/channels/sushi/</web:DisplayUrl> 
  <web:DateTime>2009-01-17T04:28:08Z</web:DateTime> 
  <web:Rank>0.066471</web:Rank> 
  </web:WebResult>
- <web:WebResult>
  <web:Title>It has to be...SUSHI SUSHI™</web:Title> 
  <web:Description>Welcome to the World of the SUSHI SUSHI Chef! Learn / Order / Contact / Explore the Kitchen... ... So that Chef can address you personally, please tell him your first name now:</web:Description> 
  <web:Url>http://www.sushisushi.com.au/</web:Url> 
  <web:DisplayUrl>http://www.sushisushi.com.au/</web:DisplayUrl> 
  <web:DateTime>2009-01-12T09:06:05Z</web:DateTime> 
  <web:Rank>0.064478</web:Rank> 
  </web:WebResult>

Figure 2: Web Results Using Count and Offset