To begin, go to the Amazon CloudSearch console at http://console.aws.amazon.com/cloudsearch.
On the Welcome page, click Create Your First Search Domain to launch the Create Domain Wizard.
The first step is to give our search domain a unique name.
We’re going to be using the IMDB sample data, so let’s call it “imdb-movies”.
Note that domain names can contain lower case letters, numbers, and dashes.
Capital letters, underscores, and other special characters are not allowed.
Next, we need to specify how we’re going to configure indexing options for our new domain.
For this demo, we’re going to use the predefined configuration for the IMDB movies sample data.
When you’re using your own data, CloudSearch can recommend an index configuration based on a sample of your data.
Or, you can configure the index fields and options yourself.
The review configuration step shows the options that will be configured for each index field.
If we need to, it’s easy to modify the configuration later through the console.
So, we’ll just accept the proposed configuration.
Until you configure access policy rules, you’ll only be able to upload documents and submit search requests to the domain through the console.
We want to be able to submit HTTP requests to our domain’s search endpoint to search for movies.
So, we’ll enable the recommended rules.
The summary shows the name of the domain we’re about to create
and the indexing options and access policy options that will be configured.
It generally takes about half an hour to fully initialize a new search domain.
A domain’s dashboard shows the domain’s status
the number of searchable documents
the number of configured index fields
the total number of search instances that are being used for the domain
the number of partitions the index has been split into
the type of search instances that are being used: small, large, or extra large
and the domain’s unique search and document service endpoints.
While resources are being provisioned for our new domain, the domain status is Initializing.
Once the domain is in the Processing or Active state
we can start uploading the documents we want to search.
To begin, click the Upload Documents button at the top of the domain dashboard.
We’re using the sample IMDB movie data
When you’re using your own data, the console can automatically convert it to the Search Document Format (SDF).
Or, you can preformat your data according to the SDF schema using either JSON or XML.
The Review Documents step shows the number of documents to be uploaded
and the document fields that were detected.
If any fields were detected that don’t match the index fields configured for the domain, they are also listed.
If you’re using the sample data or automatically converting your data to SDF
you might want to download the SDF batches that will be used to build your index.
When you upload documents, they are automatically indexed in near real time.
So, you can start searching right away.
The domain dashboard shows how many documents have been indexed are are ready to be searched.
To launch the search tester, click the domain’s Run a Test Search Link.
The Search Tester enables you to submit simple queries against all text fields or specific text or literal fields.
By default, multiple terms are ANDed together.
Let’s search the IMDB movies data for “star wars”.
When you submit a query, the search tester displays all of the available information for each hit.
In this case, each movie.
Because the genre field is configured as a facet
the Search Tester automatically enables us to drill down into the results by genre.
For example, if we narrow the results to the Animation genre
we see a single result, The Clone Wars.
When you want to match documents that contain any of the terms you specify
you can use the | (OR) operator to separate the terms.
For example, if we separate star and wars with the | operator
we get all of the movies that match either term.
Similarly, we can prefix a term with the - (NOT) operator to exclude documents that contain a particular term.
For example, if we search the title field for star wars and prefix wars with the - (NOT) operator
we get all of the movies whose titles contain the term star, but do not contain the term wars.
The Search Tester also enables you to view the actual request URL and raw response for a query.
To submit requests from your browser, you can copy and paste this URL as a starting point.
To perform Boolean queries and use the full Amazon CloudSearch query language
you submit HTTP requests directly to your domain’s search endpoint.
For example, we could construct a query to find all of the movies released between 2008 and 2010
that have the term “star” in the title field.
The first part of the URL is our domain’s unique search endpoint.
Next, we have to specify the API version that we’re using.
The current CloudSearch API version is 2011-02-01.
Then, we specify the action for our request, search.
The Boolean query parameter (bq), specifies the constraints for our search.
We’re going to search the title field for the term “star”
and the year field for the range 2008 through 2010.
Note that the Boolean operator, in this case AND, is specified as a prefix operator.
Finally, the return-fields parameter
specifies which fields we want to include in the response
in addition to the matching document IDs.
In this case, let’s the titles for each matching movie.
Now we can use a Web browser to submit the query and view the results.
Now that we’re done experimenting with our IMDB movies domain
we’ll delete it to avoid racking up additional charges.
To delete a domain, go to the domain dashboard and click Delete this Domain.
When prompted, confirm that you really want to delete the domain and click OK.
It takes about 15 minutes to completely remove the domain and all of its resources.
For more information about setting up your own search domains
see the Amazon CloudSearch Developer Guide.
For pricing information, see the Amazon CloudSearch Overview on aws.amazon.com.
If you have questions about Amazon CloudSearch
or want to hear what other CloudSearch developers are talking about
visit the CloudSearch Forum.