Тёмный

Using geospatial searches with DynamoDB 

Ask James About AWS
Подписаться 495
Просмотров 4,1 тыс.
50% 1

Searching for the nearest or farthest location is easy thanks to DynamoDB and a small geocoding NPM package. Got a question for James? Ask me on Twitter @jbesw.

Опубликовано:

 

4 авг 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 48   
@mohammedgt8102
@mohammedgt8102 3 года назад
Great work James. This is precisely what I was looking for.
@alihussnain5548
@alihussnain5548 5 лет назад
hats off. Thanks Great JOB.
@mdibound
@mdibound 5 лет назад
Great intro. Thanks, James!
@AskJamesAboutAWS
@AskJamesAboutAWS 5 лет назад
Thanks John!
@reactdb6039
@reactdb6039 4 года назад
great video James. just wondering how you could add extra query parameters to the search just as starbucks within 1km that sell a certain type of coffee and are a certain size.
@AskJamesAboutAWS
@AskJamesAboutAWS 4 года назад
You would have to modify the library but it could be done fairly easily.
@aakashpatil989
@aakashpatil989 2 года назад
I am facing issues while plotting the starbucks locations on the front end. I have purchased the google maps api and configured the dynamodb table too. If you could please help me finding out the exact issue is? can we connect for some time?
@sebastianmeckovski9980
@sebastianmeckovski9980 7 месяцев назад
Hello from 2023. Will this approach work if I also want to order by distance from my geo location?
@aakashpatil6647
@aakashpatil6647 2 года назад
Great work James, If we change the AWS region, will that affect the run-time for larger queries? for eg. If I am in Ireland and set the region to Ireland and run the query & in another instance, set the region to Australia and run a query, will there be any difference in execution time due to latency? (note: my original location is Ireland)
@aakashpatil6647
@aakashpatil6647 2 года назад
This is a part of my research project to use DynamoDB to query Geospatial databases in physically closest and furthest regions and compare latency in execution times. It would be very helpful if you could answer this for me
@JamesBeswickD
@JamesBeswickD 2 года назад
Hello! The execution time within the AWS services will not be affected by the Region choice, but the latency from your device to reach that Region will increase. Generally, it's best to run the solution in a Region close to your users since the geographic latency is largely unavoidable.
@aakashpatil6647
@aakashpatil6647 2 года назад
@@JamesBeswickD Can I then load a dataset into an S3 bucket in Ireland, run Lambda in Ireland and an EC2 instance in Australia to process the same data with same program for comparison among both performances? Will that produce any latency ? If no, could you please suggest any changes in my project as I want to show Fog and Edge( Computation in home location) faster and better than geographically distant Cloud. (I am assuming my EC2 in Australia will need some time to fetch S3 data from Ireland: Hope that's correct)
@JamesBeswickD
@JamesBeswickD 2 года назад
@@aakashpatil6647 Loading data between regions introduces latency because you are moving data from one region to another. Generally, it's better to do the compute in the same region as where the data is stored. You may also be charged from cross-region data transfer. In comparing fog/edge with cloud, "better" is highly subjective and will depend on your architecture and use case.
@aakashpatil6647
@aakashpatil6647 2 года назад
@@JamesBeswickD Thanks a lot James! This shall definitely shape the course of my study!
@orrlevinger
@orrlevinger 3 года назад
How would add this querying capabilities to an existing table?
@JamesBeswickD
@JamesBeswickD 3 года назад
Hi! This library manages its own table, so it's not possible to do this. However, you could modify this library to use an existing table or extract the geohash logic into your own library.
@reactdb6039
@reactdb6039 4 года назад
Just wondering why you use a post to query rather than a get.
@JamesBeswickD
@JamesBeswickD 4 года назад
Good question! This was a remnant from how the demo originally worked - I trimmed it down, so now it should GET instead.
@andresm9051
@andresm9051 3 года назад
Hi there, great video congrats, I tested out I works like a charm, but I need something like this to know what are closest stores to the farthest one, in a city or a specific country, aswell applying a filter based on if the store has home-delivered for coffee to same city or country what you recommend me ?
@JamesBeswickD
@JamesBeswickD 3 года назад
Hi Andres! The library used in this video doesn't support complex use cases that you could otherwise solve with composite keys or GSIs in DynamoDB. However, you can take the core of the library and extend this to address this issue, if you want to have the database filter the records on these factors. The core geohashing calculation is only a few dozen lines of code. As a quick fix, if there aren't many items that would be filtered out (e.g. most results from a geohash are in the correct country), you could also create a post-process filter in the Lambda function called by API Gateway. It's not the most efficient solution but it might help solve it quickly.
@andresm9051
@andresm9051 3 года назад
@@JamesBeswickD ok, thanks a lot for the response, I was thinking of modifying the lib, but I found another way like this: Linking the coffee to the store using a gsi, with PK = store ID, SK = coffee ID And reuse the same gsi with the GSI-PK = coffeID and GSI-SK = LOCAL#MIAMI Using this approach I can say bring all coffees with home-delivering in the Miami city or PK = coffeID and SK = NATIONAL#US With this approach I can bring all coffees that has national shipping to US Or event better bring all coffee that has national shipping, local or by store what do you think ?
@JamesBeswickD
@JamesBeswickD 3 года назад
@@andresm9051 Yeah, I think you nailed it. The way you use the GSIs in your example is really one of the key principles to bringing flexible filters to DynamoDB. Nicely done!
@andresm9051
@andresm9051 3 года назад
@@JamesBeswickD Thanks a lot, I saw your video, severals time then I wonder how to solve in a different way, great content in your channel, congrats!! do you provide consulting services? I will reach you by twitter
@JamesBeswickD
@JamesBeswickD 3 года назад
@@andresm9051 Thanks! I am a Developer Advocate for AWS Serverless - see you on Twitter!
@smitaagarwal6002
@smitaagarwal6002 4 года назад
Great tutorial James. I was trying out to create the table through setup code, but somehow it's not doing anything and no error. Does it work with Node 12 as version 8 is no longer supported by AWS Lambda.
@JamesBeswickD
@JamesBeswickD 4 года назад
Thanks! When you run the setup script (gitlab.com/jbesw/askjames-caffeinate-me/-/blob/master/local/setup.js), this defaults to us-east-1, so just check your region. Also, running this from the CLI, you will need to ensure your CLI role has permissions for these resources. It works exactly the same way with Node 12. I'm going to be revisiting this geohashing project in some new videos and content soon to make the process clearer. HTH!
@smitaagarwal6002
@smitaagarwal6002 4 года назад
@@JamesBeswickD Thanks James for the quick reply, I am running directly from AWS Lambda. I sorted out the problem, Lambda was executing without waiting for the table creation operation to complete, so adding "await" solved the problem: await ddb.createTable(createTableInput).promise() // Wait for it to become ready .then(function () { return ddb.waitFor('tableExists', { TableName: config.tableName }).promise() }) .then(function () { console.log('Table created and ready!') }) It has created 2 columns, hashKey and rangeKey
@smitaagarwal6002
@smitaagarwal6002 4 года назад
One more question James, while running the radius based query is it possible to return the results page wise. Let's say in the batches of 10 results - ordered closer to farther.
@JamesBeswickD
@JamesBeswickD 4 года назад
@@smitaagarwal6002 Not with this library - the documentation says: "Although low level DynamoDB Query requests return paginated results, this library automatically pages through the entire result set. When querying a large area with many points, a lot of Read Capacity Units may be consumed."
@smitaagarwal6002
@smitaagarwal6002 4 года назад
@@JamesBeswickD Hi James, I have a question which is not related to Geo library but in general, with Dynamo concept - let's say for eventually consistent read type, the number of records returned is 5 but the overall size of data returned for all 5 items is less than 4KB, will it be counted as 5 RCUs or 1RCU?
@rahulshah6886
@rahulshah6886 4 года назад
Great info. Can i know whether this can be implemented in java as well?
@AskJamesAboutAWS
@AskJamesAboutAWS 4 года назад
Hello! Yes - this library is actually a port of an original Java library which you can find here: github.com/amazon-archives/dynamodb-geo.
@rahulshah6886
@rahulshah6886 4 года назад
@@AskJamesAboutAWS Thanks for your quick reply
@rahulshah6886
@rahulshah6886 4 года назад
@@AskJamesAboutAWS I am stuck in between. can i get a source code for this.
@JamesBeswickD
@JamesBeswickD 4 года назад
@@rahulshah6886 The source code for this video is at gitlab.com/jbesw/askjames-caffeinate-me.
@mithunp3826
@mithunp3826 3 года назад
how do you connect to aws dynamodb
@JamesBeswickD
@JamesBeswickD 3 года назад
Hi - take a look at aws.amazon.com/blogs/compute/implementing-geohashing-at-scale-in-serverless-web-applications/. I write here in more detail about how this works, and there's also a code repo you can use. HTH!
@aakashpatil3228
@aakashpatil3228 2 года назад
Can you please provide the github link to the codes?
@JamesBeswickD
@JamesBeswickD 2 года назад
Hi! It's at 3:15 in the video - gitlab.com/jbesw/askjames-caffeinate-me.
Далее
Geohash: the algorithm inside and out - Part 1
15:37
Caffeinate me! Using VueJS to query your API Gateway
10:55
Restore an EC2 snapshot to the same instance
8:27
Просмотров 21 тыс.
Rust Data Modelling Without Classes
11:25
Просмотров 167 тыс.