Search code examples
amazon-web-servicesamazon-cloudsearch

Update CloudSearch document using Python boto


I am using the latest boto tools for Python to add and search documents on Amazon CloudSearch. I haven't been able to find any documentation regarding the updates of documents. There is documentation for the old API here: http://boto.readthedocs.org/en/latest/cloudsearch_tut.html. Here, when adding a document you give a version number, and to quote the docs:

If you wish to update a document, you must use a higher version ID.

However, I don't find this feature in the boto namespaces for the new API (the ones with cloudsearch2). The add function no longer takes a version.

Currently what I am doing to update a document is getting it by ID, then adding it again. The logic of updating the fields is on my side.

What would be nice is to add a document with the same ID and higher version number and only fill in the fields that you want overridden, and the document should be updated.

Is there still a way to use the version of a document in the new boto API?


Solution

  • There is no way to use 'version' with the new boto API (cloudsearch2) because that library is built for CloudSearch version 2013-01-01, which removed the version field.

    CloudSearch also does not allow you to selectively update certain fields of a document, although I agree that would be useful. This was not possible with the old version either.

    This describes the SDF format for submitting documents that boto is implementing for you, in case you want to have a look at the underlying interface. http://docs.aws.amazon.com/cloudsearch/latest/developerguide/preparing-data.html