user1578872
user1578872

Reputation: 9118

AWS CloudSearch Java API

We are using EC2 and RDS( MySQL ) in AWS cloud. Planning to use Amazon CloudSearch for full text search. It looks like, we need to send the data to CloudSearch whenever we add a new row in MySQL. Its a kind of 2 operation to keep CloudSearch in sync with RDS. One to add a row to RDS and a second operation to add the same data( of course in a different format ) to CloudSearch. Please suggest me if there is any other good approach.

I am looking for good materials and working example for AWS java api to add, a doc to cloudsearch and update/delete a doc whenever there is an update to RDS.

Thanks, Baskar.S

Upvotes: 2

Views: 2023

Answers (2)

Sean Roy
Sean Roy

Reputation: 356

Nikhil is halfway there. In the code where your data is CRUD'd you add the analogous calls to cloudsearch, but both of these statements need to be wrapped in a transactional context. This basically ensures that if one fails, they both fail. Without this you can never guarantee synchronization.

Frameworks such as Spring and Rails provide this functionality, but you haven't stated what you're using.

Upvotes: 1

Nikhil
Nikhil

Reputation: 3152

While there are no readymade tools to ensure a constant sync between your RDS database and your cloudsearch index, the problem is usually solved by adding your own code to your update/delete/create functions. I've used this approach in my ruby based web-app.

Let's assume you've got a class that handles adding new document to your index, updating a document and deleting a document. Your approach should be as below:

  1. When a new row is successfully created, call the function that also creates a new document. This is automatically indexed by cloudsearch on completion.

  2. When you update a row and make changes to a field which is also present in your cloudsearch index, call the function that updates the corresponding document as well.

  3. Likewise for deleting a row, call the function that deletes the document from the index as well.

Upvotes: 4

Related Questions