Our company is using AWS CloudSearch to search and retrieve user data.User data consists of a field position of type lat,lon. So for a given radius and position we should find all the users in the range of radius. How to write search query to retrieve required data ?
We are using node.js as server side language .
Please help .
Radius Based Search on lat,lon in AWS CloudSearch
2.3k views Asked by Sri Harsha At
2
There are 2 answers
0
alexroussos
On
You want to be ranking results based on the haversin function. That is equivalent to "searching within a radius" except it accounts for the fact that you're actually interested in the distance on the surface of a sphere.
Here is an example of such a query with CloudSearch (from http://docs.aws.amazon.com/cloudsearch/latest/developerguide/searching-locations.html):
q=restaurant&expr.distance=haversin(35.621966,-120.686706,location.latitude,location.longitude)&sort=distance asc
Your choice of server-side language is irrelevant, as CloudSearch provides only a REST interface. Have a look at the Getting Started guide if you haven't yet. http://docs.aws.amazon.com/cloudsearch/latest/developerguide/getting-started.html
Related Questions in JAVASCRIPT
- Using Puppeteer to scrape a public API only when the data changes
- inline SVG text (js)
- An array of images and a for loop display the buttons. How to assign each button to open its own block by name?
- Storing the preferred font-size in localStorage
- Simple movie API request not showing up in the console log
- Authenticate Flask rest API
- Deploying sveltekit app with gunjs on vercel throws cannot find module './lib/text-encoding'
- How to request administrator rights?
- mp4 embedded videos within github pages website not loading
- Scrimba tutorial was working, suddenly stopped even trying the default
- In Datatables, start value resets to 0, when column sorting
- How do I link two models in mongoose?
- parameter values only being sent to certain columns in google sheet?
- Run main several times of wasm in browser
- Variable inside a Variable, not updating
Related Questions in NODE.JS
- Using Puppeteer to scrape a public API only when the data changes
- How to request administrator rights?
- How do I link two models in mongoose?
- Variable inside a Variable, not updating
- Unable to Post Form Data to MongoDB because of picturepath
- Connection terminated unexpectedly while performing multi row insert using pg-promise
- Processing multiple forms in nodejs and postgresql
- Node.js Server + Socket.IO + Android Mobile Applicatoin XHR Polling Error...?
- How to change the Font Weight of a SelectValue component in React when a SelectItem is selected?
- My unban and ban commands arent showing when i put the slash
- how to make read only file/directory in Mac writable
- How can I outsource worker processes within a for loop?
- Get remote MKV file metadata using nodejs
- Adding google-profanity-words to web page
- Products aren't displayed after fetching data from mysql db (node.js & express)
Related Questions in AMAZON-WEB-SERVICES
- S3 integration testing
- How to get content of BLOCK types LAYOUT_TITLE, LAYOUT_SECTION_HEADER and LAYOUT_xx in Textract
- Error **net::ERR_CONNECTION_RESET** error while uploading files to AWS S3 using multipart upload and Pre-Signed URL
- Failed to connect to your instance after deploying mern app on aws ec2 instance when i try to access frontend
- AWS - Tab Schema Conversion don't show up after creating a Migration Project
- Unable to run Bash Script using AWS Custom Lambda Runtime
- Using Amazon managed Prometheus to get EC2 metrics data in Grafana
- AWS Dns record A not navigate to elb
- Connection timed out error with smtp.gmail.com
- AWS Cognito Multi-tenant Integration | Ok to use Client’s Idp?
- Elasticbeanstalk FastAPI application is intermittently not responding to https requests
- Call an External API from AWS Lambda
- Why my mail service api spring isnt working?
- export 'AWSIoTProvider' (imported as 'AWSIoTProvider') was not found in '@aws-amplify/pubsub'
- How to take first x seconds of Audio from a wav file read from AWS S3 as binary stream using Python?
Related Questions in GEOSPATIAL
- Estimating distance between points and its relative elevation for multiple countries and geometries, using R sf
- Folium Timestampedgeojson - How to add dynamic html for the title of the map
- Convert lat,lon,data points to matrix (2D grid) at 0.5 degree resolution in Python
- Having trouble merging these two datasets for a Spatial Analysis
- How to extract vineyard land cover from CORINE in R?
- find point in inside polygon ..with mysql
- map distance in pixels to meters
- Efficiently Turn Matrix of Intersecting Routes Into Simplified Spatial Network (Graph)
- Oracle SDO_INTERSECTION returning null where an intersection exists in SRID 4326
- Plotting data on shapefile with the same CRS, but things are not lining up as I would expect
- get the band with the maximum value from a xarray stack
- Can spatial features be used as an input for a machine learning model?
- Make SpatRaster from sf point object
- Apache Sedona Version Issues
- MemoryError: Unable to allocate 19.1 GiB for an array with shape (52199, 49069) and data type int64
Related Questions in AMAZON-CLOUDSEARCH
- Specify custom rank expression for AWS Cloudsearch
- New client-cloudsearch-domain SDK domain spec
- How can I update an API Gateway service-linked role with a policy to access CloudSearch in AWS?
- AWS Cloud Search Search Index Domain Split Across 12 Partitions
- Do we need to make any change to java code in Solr while migrating to aws cloudsearch
- Is there a way to decrease the Dynamodb event source batch size limit to 5MB? Trying to upload documents to Cloudsearch
- Integrating AWS CloudSearch with .NET Core and AWS RDS
- Is there a limit on the number of filters that can be passed to DynamoDB query
- CloudSearch filtered query works in test dashboard but not on search endpoint
- How to do partial text search in Cloudsearch
- How to get list of available AWS services in a region from boto3 call
- How we can trigger a REST API after successful resource creation in terraform
- What is latest version available for AWS cloudsearch access policy?
- How to get aws cloudsearch domain's search endpoint using AWS Java sdk
- Amazon cloudsearch: Fuzzy search by field with boto3
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
In cloudsearch it is not possible to search Latlons within a radius. You can order by distance, but you can search within a radius.
Since you want all the results within a radius. Instead create a rectangle such that it's four side touches the circle you want to search in. Now, you can search inside a bounding box rectangle and return the results sorted by distance.
The disadvantage is there will be some results which are on the corners of bounding box, so they are not in circle but they will come up in cloudsearch result. You can either use those as well as a approximation or filter further based on distance.
Here is a example query which does the same : q=user*&fq=location%3A%5B%2740.628611,-100.694152%27,%2725.621966,-66.686706%27%5D&expr.geo=haversin%2838.958687,-77.343149,location.latitude,location.longitude%29&sort=geo%20asc
here : fq=location%3A%5B%2740.628611,-100.694152%27,%2725.621966,-66.686706%27%5D ---> searches within the bounding box Latlons i.e. upper-left corner and lower right corner.
expr.geo=haversin%2838.958687,-77.343149,location.latitude,location.longitude%29&sort=geo%20asc ---> creates a expression which computes distance between LatLon in search document to a fixed point(give this as center of your circle). and returns result sorted by distance.
Note that the "haversin" distance function computes distance between LatLons as distance between two points on a perfect sphere.