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...

Adding and Updating Documents in Amazon CloudSearch

An add operation specifies either a new document that you want to add to the index or an existing document that you want to update.

When you add or update a document, you specify the document's ID, a new version number, the document language, and all of the fields the document contains. If a document field matches the name of an index field, it is automatically used as the source for that index field. You can also explicitly map one or more document fields to an index field. You don't have to specify every configured field for every document—documents can contain a subset of the configured fields. Document fields that are not used as a source for at least one index field are ignored during indexing.

Important

You must specify a new, larger version number every time you add or update a document. For more information, see Document Versions in Amazon CloudSearch.

To add a document to a search domain

  1. Specify an add operation in your SDF data that contains the id of the document you want to add and each of the fields that you want to be able to search or return in results. If you are updating an existing document, the version number must be greater than the document's current version number for the update to be applied. For example, the following operation would add version 1 of document tt0484562:

    [
     { "type": "add",
      "id":   "tt0484562",
      "version": 1,
      "lang": "en",
      "fields": {
        "title": "The Seeker: The Dark Is Rising",
        "director": "Cunningham, David L.",
        "genre": ["Adventure","Drama","Fantasy","Thriller"],
        "actor": ["McShane, Ian","Eccleston, Christopher","Conroy, Frances",
                  "Crewson, Wendy","Ludwig, Alexander","Cosmo, James",
                  "Warner, Amelia","Hickey, John Benjamin","Piddock, Jim",
                  "Lockhart, Emma"]
      }
     }
    ]
  2. Send the SDF data to your domain. You can submit data updates through the Amazon CloudSearch console, using the cs-post-sdf command, or by posting a request directly to the domain's document service endpoint. For more information, see Uploading Data to an Amazon CloudSearch Domain.