I hope you are able to figure out a possible approach to update the clouds which is next on the fly.
Solution is simple very simple.
And we have used this process already a couple of times in this course and you might have already guessed
it.
We're going to is dynamo Davies dreams along with Louderback trigger to upload the changes to Klaus's.
So let's do that.
Our Global TV stable already has streams and Nabl with old and new images.
We just need to create a new land at Treanor to upload the changes to cloud search said let's create
a new folder
open it the code and let's initialize a new mode project with NPR and
just like that.
Install a business SDK as usual
create an index or just fine to hold our land function inside the file reference.
The as the.
And initialize an object.
Our Lives SEAGE to make less
this time.
The End Point is going to be the document and point and not the search point because we want to upload
documents to ourselves and Mark actually from the searches said Copy the document and point from cloud
search console and pasted in here.
Then let's write the handler function for lambda a space dog handler.
You rant on text and call the and the dynamo these three red cards will be available in the event.
Dark red cards at the age of 10 when the intervening item data in a format are required by a large search
API.
And we can do that using the map function.
Max function simply is a custom function on every element of an entity and it is a new we are going
to use the asynchronous version of the map function using the a saying and more.
You said let's install a sing using and install a single dash dash.
Save and then run city code
then inside the Landauer handler we can call the map method
a saying door map B and A which is event to dart cars.
In our case I already function that takes in car and call back
let's call it call back.
Matt just to differentiate it from the main call that then the final callback are the function louses
API provides two operations add and delete.
We use the add to add new documents or to update existing ones and then later remove existing documents
from the clouds in less.
So for each record we specify the operation type on the or delete followed by the unique ID of the document.
And then the data base ascii value is in case there is see or room event from this train we issue a
delete operation as we issue an ad operation.
Now if you run a search on Blough search you will notice that allowed search generates a unique ID.
We are trying to move the item using the primary key to partition key and hash key separated by an underscore
correct.
So in our function we must force the ID in the same format say for a car door event name equals the
No.
Then we turn the call back map with an object with type delete and tidy as user ID and time stamp call
calculated by an honest less populated user ID and time.
Just like that.
In the event name is anything Bartiromo we issue an the races in that as long callback map and return
the object with type and an ID as ID and the leaves to add licet these is an object with key value pairs
are dynamo Leavey item attributes Bede's should be a rainbow in the new image attribute in the event
stream.
So let's declare a variable to point to new image and then we can use it to populate all the item to
use these will be the column names from Blauser and Raley's will be the corresponding Raley's from the
dynamo the item
now we should have the resulting batch of documents to be uploaded rentable in the SOS object in the
final callback.
The last step is to call the upload documents method or the cloud system and class so see as the dot
load documents caroms callback
and inside the parents we have to specify Content-Type applications.
Jason
and document that would be the results object converted to Jason using Jason.
There are springeth
Arlanda operation is ready let's create a package.
As usual then the contents of the folder
and then remove the age of us as the Kapler ran inside the margins for
open the dynamo console.
And on that triggers tab key to the new fashion.
And it take us to the land console.
I'm going to name the function as a date cloud sewage from Diabaly
we'll create a new role.
Call it land or cloud message.
Dan
Roop policy document and they did.
And I'm going to Baystate and Jason policy right Grant permission to land are allowed to charge a large
surge and ultimately the Danimal streams I have attached the policy Jason document in the sources section
of this video for your use as well.
And enable the trigger and a function
and then we simply upload our code here.
Let's increase the timeout 2 to 1 minute and save the function.
Now to test if this works I'm going to delete.
Am I to duplicate any existing item and also modify an existing item to see if the change reflects in
clouds which an ongoing in the user id be formulating.
And then this item that's duplicated is and change the partition key to some random data.
Note the new p.
And then let's also modify another item.
And neighed the partition key is that.
All right.
Let's see.
The land functions if you did all that Krieger's stab hits with fresh and you can see that last result
was successful.
And if you look at cloud watch longs
we see that one item was deleted and two were added are dated.
Let's finally verify this from Plow's search.
Consul the first search for the delete key.
Now we see that there are no reasons searching by the other two.
He should give us the latest results.
And
what Austin said that able to update our search results on the fly using diamante these screams and
land outriggers that completes our them or our search.
Next up is cloud watch and we're very familiar with cloud watch.
There is a lot in this course.
Yes in the next section we're going to take a closer look at the cloud what there is and use it more
effectively.