|« PreviousNext »|
|Did this page help you? Yes | No | Tell us about it...|
You can use the search tester in the Amazon CloudSearch console to perform simple text searches. To perform more complex Boolean queries, you can submit search requests through a Web browser or send HTTP requests using cURL or any HTTP library.
The search tester enables you to choose which fields you want to search, sort the results, and browse any facets that are configured for the domain. By default, results are sorted according to an automatically-generated relevance score, text_relevance. (For more information about customizing how results are ranked, see Customizing Result Ranking with Amazon CloudSearch.)
To search your domain
Go to the Amazon CloudSearch console at Amazon CloudSearch console.
In the Navigation panel, click the name of your movies domain.
In the Navigation panel, click the Run a Test Search link for your movies domain.
Select the field(s) you want to search, enter the text you want to search for, and click Go.
To view the HTTP search request that was sent to your domain's search endpoint and the JSON or XML response returned by Amazon CloudSearch, click the view raw link for the response format you want to see.
You can copy and paste the request URL to submit the request and view the response from a Web browser. Requests can be sent via HTTP or HTTPS.
To perform more complex searches, you can submit your own search requests directly to your search endpoint. You can perform simple and Boolean searches and specify a variety of options to constrain your search, request facet information, customize ranking, and control what information is returned in the results.
For example, to search your movies domain and get the titles of all of the available Star Wars movies, append the following search string to your search endpoint. (2011-02-01 is the API version and must be specified.)
Your domain's search endpoint is shown on the domain dashboard. You can also perform a search from the AWS Management Console, view the raw request and response, and copy the request URL from the Search Request field.
By default, Amazon CloudSearch returns the response in JSON. You can also get the search results formatted in XML by specifying the results-type
results-type=xml. (Errors are always returned in JSON.) The following image shows the results of the previous query.
You can use the Boolean query option,
bq, to find documents that have particular numeric attributes. You can filter based on an exact value in a field, an inequality, or a range of values, as in these examples:
bq=year:2000 matches documents with the year 2000.
bq=year:2000.. matches documents with a year greater than or equal to 2000
bq=year:..2000 matches documents with a year less than or equal to 2000
bq=year:2000..2011 matches documents with a year between 2000 and 2011, inclusive.
For example, the following Boolean query searches for "star", finds all of the matching movies that were released before 2000, and returns title and year of each one:
2011-02-01/search?bq=(and 'star' year:..2000)&return-fields=title,year
The response shows the number of matching documents and the requested fields for each hit.
For more information about constructing search queries, see Searching Your Data with Amazon CloudSearch.
By default, Amazon CloudSearch ranks the search results according to an automatically generated text_relevance score. You can change how results are ranked by specifying the rank option in your search request to specify the field or rank expression you want to use for ranking. (A rank expression is a custom numeric expression that can be evaluated for each document in the set of matching documents. For information about defining your own rank expressions, see Customizing Result Ranking with Amazon CloudSearch.)
If you specify a text field with the rank option, the results are sorted alphabetically according to that field. For example, to rank results from your movies domain alphabetically by title, add
&rank=title to your query string:
2011-02-01/search?bq=(and genre:'sci-fi' year:..2000)&return-fields=title,year&rank=title
When you rank alphabetically, the results are sorted in ascending order by default. Any values that begin with a numeral are listed before the first A entry:
Similarly, you can specify an integer field with the
rank option to sort the results numerically.
By default, when you rank alphabetically or numerically, results are returned in ascending order. You can prefix the field name with a minus (-) if you want the results returned in descending order. If you specify a comma separated list of fields or rank expressions, the first field or expression is used as the primary sort criteria, the second is used as the secondary sort criteria, and so on.
For more information about ranking results, see Customizing Result Ranking with Amazon CloudSearch
A facet is an index field that represents a category that you want to use to refine and filter search results. When you submit search requests to Amazon CloudSearch, you can request facet information to find out how many hits share the same value in a facet. You can display this information along with the search results and use it to enable users to interactively refine their searches. (This is often referred to as faceted navigation or faceted search.)
A facet can be any numeric field or a text or literal field that has faceting enabled in your domain configuration. To request facet information in your search request, you specify:
One or more facets
Facet constraints that specify the particular values you want to count (optional)
How you want the facet values to be sorted in the results (optional)
For each facet, Amazon CloudSearch calculates the number of hits that share the same value. If you specify constraints, the facet counts are calculated only for values that match the constraints. Only constraints that have matches are included in the facet results.
Values from a facet-enabled text or literal field cannot be returned in the search results. Text and literal fields can be facet-enabled or result-enabled, but not both. If you want to return the value from an SDF document field as well as use the field as a facet, create two index fields that use the same SDF document field as a source and make one result-enabled, and the other facet-enabled.
To get facet counts with your search results
Use the facet option to specify the fields for which you want to compute facets. For the sample IMDB movies data faceting is enabled for one field, genre.
The facets appear below the hits in the results.
If you want to compute facet counts for selected values of a facet field, you can set facet constraints for the field. Facet constraints do not constrain the results themselves, only the facet counts that are returned. For example, the following request only counts the movies that are in the Sci-Fi, Fantasy, or Thriller genres:
This constrains the facet counts to the three specified values:
For more information about faceted searches, see Getting and Using Facet Information in Amazon CloudSearch.