Amazon CloudSearch
Developer Guide (API Version 2011-02-01)
« PreviousNext »
View the PDF for this guide.Go to the AWS Discussion Forum for this product.Go to the Kindle Store to download this guide in Kindle format.Did this page help you?  Yes | No |  Tell us about it...

Search Response

When a request completes successfully, the response body contains the search results. By default, search results are returned in JSON. If the results-type parameter is set to XML, search results are returned in XML.

When a request returns an error code, the body of the response contains information about the error that occurred. Error responses are always returned in JSON. If an error occurs while the request body is parsed and validated, the error code is set to 400 and the response body includes a list of the errors and where they occurred.

The following example shows a JSON response.

{
   "rank":"-text_relevance",
   "match-expr":"(label 'star wars')",
   "hits":{
      "found":7,
      "start":0,
	  "hit":[
	     {"id":"tt1185834",
		     "data":{
			    "actor":["Abercrombie, Ian","Baker, Dee","Burton, Corey"],
				"title":["Star Wars: The Clone Wars"]
			 }
		 },
		 .
		 .
		 .
		 {"id":"tt0121766",
		     "data":{
			    "actor":["Bai, Ling","Bryant, Gene","Castle-Hughes, Keisha"],
				"title":["Star Wars: Episode III - Revenge of the Sith"]
			 }
		 }
	   ]
	},
	"info":{
	   "rid":"b7c167f6c2da6d93531b9a7b314ad030b3a74803b4b7797edb905ba5a6a08",
	   "time-ms":2,
	   "cpu-time-ms":0
	}
	} 

The following example shows the equivalent XML response:

<?xml version="1.0" encoding="UTF-8"?>
   <results xmlns="http://cloudsearch.amazonaws.com/2011-02-01/results">
      <rank>-text_relevance</rank>
   	  <match-expr>(label 'star wars')</match-expr>
   	  <hits found="7" start="0">
   	     <hit id="tt1185834">
   	     	<d name="actor">Abercrombie, Ian</d>
   	     	<d name="actor">Baker, Dee</d>
   	     	<d name="actor">Burton, Corey</d>
   	     	<d name="title">Star Wars</d>
   	     </hit>
   	  	 .
   	  	 .
   	  	 .
   	  	 <hit id="tt0121766">
   	  	 	<d name="actor">Bai, Ling</d>
   	  	 	<d name="actor">Bryant, Gene</d>
   	  	 	<d name="actor">Castle-Hughes, Keisha</d>
   	  	 	<d name="title">Star Wars: Episode III - Revenge of the Sith</d>
   	  	 </hit>
   	  </hits>
   	<facets/>
   	<info 
   		rid="b7c167f6c2da6d93531b9a7b314ad030a5ddfe34efbdd8959999ac792f37a1f" 
   		time-ms="2" 
   		cpu-time-ms="0"
   	/>
</results>

Search Response Headers

NameDescription
Content-TypeA standard MIME type describing the format of the object data. For more information, see W3C RFC 2616 Section 14.

Default: application/json

Constraints: application/json or application/xml only

Content-LengthThe length in bytes of the body in the response.

Search Response Properties (JSON)

PropertyDescription
match-exprShows the match expression constructed from the search parameters.
hitsContains hit statistics (found, start) and a hit array that lists the document ids and data for each hit.
foundThe total number of hits that match the search request after Amazon CloudSearch finished processing the match set.
startThe index of the first hit returned in this response.
hitAn array that lists the document ids and data for each hit.
idThe unique identifier for a document.
dataA list of returned fields.
facetsContains facet information and facet counts.
FacetFieldNameA field for which facets were calculated.
constraintsAn array of the facet values and counts.
valueThe facet value being counted.
countThe number of hits that contain the facet value in FacetFieldName.
infoContains information about the request processing.
rankLists the fields that were used to rank the search hits.
ridThe encrypted Resource ID.
time-msHow long it took to process the search request in milliseconds.
cpu-time-msThe CPU time required to process the search request in milliseconds.
messagesContains any warning or error messages returned by the search service. The severity, code, and message properties are included for each warning or error.
severityWhether the message is a warning or error.
codeThe warning or error code. The search service returns the following warnings and errors:
  • WildcardTermLimit—more than 2000 terms matched the wildcard in the search request. The number of terms matched was limited to 2000.

  • InvalidFieldOrRankAliasInRankParameter—the specified ranking field could not be found.

  • UnknownFieldInMatchExpression—a field specified in the bq parameter could not be found.

  • IncorrectFieldTypeInMatchExpression—the type specified in the match expression does not match the field type.

  • InvalidMatchExpression—the match expression could not be parsed.

  • UndefinedField—an unknown field was specified in the match expression.

messageA description of the warning or error that was returned by the search service.

Search Response Elements (XML)

NameDescription
resultsIf the request was successful, contains the search results. If an error occurs, the info element lists the warnings or errors that were returned by the search service.
rankLists the fields that were used to rank the search hits.
match-exprShows the match expression constructed from the search parameters.
hitsContains hit statistics and a collection of hit elements. The found attribute is the total number of hits that match the search request after Amazon CloudSearch finished processing the results. The contained hit elements are ordered according to their text_relevance scores or the rank option specified in the search request.
hitA document that matched the search request. The id attribute is the document's unique id. Contains a d (data) element for each returned field.
dA field returned from a hit. Hit elements contain a d (data) element for each returned field.
facetsContains a facet element for each facet requested in the search request.
facetContains a constraint element for each value of a field for which a facet count was calculated. The facet-FIELD-top-n request parameter can be used to specify how many constraints to return. By default, facet counts are returned for the top 40 constraints. The facet-FIELD-constraints request parameter can be used to explicitly specify which values to count.
constraintA facet field value and the number of occurrences (count) of that value within the search hits.
infoInformation about the request processing. The rid attribute is the encrypted Resource ID. The time-ms attribute is how long it took to process the search request, in milliseconds. The cpu-time-ms attribute is the CPU time required to process the search request, in milliseconds.
messageInformation about a warning or error returned by the search service while processing the request. The severity attribute is either warning or error. The code attribute specifies one of the following warning or error codes:
  • WildcardTermLimit—more than 2000 terms matched the wildcard in the search request. The number of terms matched was limited to 2000.

  • InvalidFieldOrRankAliasInRankParameter—the specified ranking field could not be found.

  • UnknownFieldInMatchExpression—a field specified in the bq parameter could not be found.

  • IncorrectFieldTypeInMatchExpression—the type specified in the match expression does not match the field type.

  • InvalidMatchExpression—the match expression could not be parsed.

  • UndefinedField—an unknown field was specified in the match expression.