ES newbie here.
I have an index of users with boundaries eg north, south, east, west. These boundaries are where they are willing to work. I also have their home address lat, lng and the radius of the circle that gives me the bounds.
I then want to search a given lat, lng and get results based on users that are prepared to travel to this location. EG, with their bounds.
Reading the docs, I can't see if this is currently possible. From my understanding I will need to do two searches (Or one search then filter).
• First do a geo_distance search with say 100miles from my lat, lng
• Then filter these results with a geo_bounding_box to see they fall into params.
It doesn't seem like a great way to go. Is there a better option? It is worth noting that a lot of these documents are new and I can easily reformat if needed.
Any suggestions on the right way to go about this?
Is there a filter I can use to see if my lat, lng are with the bounds?
Thanks in advance for your help. Cheers.
Related
I'm not sure how to word that question, so I apologize for any trouble in understanding.
I've given Geocoordinates (Lat, Long) and a radius of N kilometers.
We've also given a database with documents containing geocoordinates.
Now my task is to check if any of those documents' coordinates is within the radius.
I'm not sure how I can check if the coordinates are in the radius or not. I saw that the Google Maps API supports reverse geocoding, but I couldn't really find anything usable.
I hope someone can help to get me in the right direction!
Edit: I'm using MongoDB to store my event documents (contains an array with the lat and long)
I have coordinates, which are assigned a corresponding geohash in my database. Now I want to retrieve all of the coordinates within two bounding coordinates (top right and top left corner). How can I do that properly?
I tried getting the geohash that fits both of those bounding coordinates, but this solution does not work when they are in completely different regions of the world (so they are not sharing anything in common).
Is there a better way to do that?
Thanks for your help
Unfortunately, this isn't something you can do out-of-the-box with datastore / App engine. (There are no built in spatial queries.)
For early prototyping, etc., you can do it the hard way - retrieve all the rows, and discard the ones not meeting your query in code. Obviously, probably not viable with real production data.
See related question Query for Entities Nearby with Geopt for some possible production solutions.
Is it possible to search venues (via venues/search) in whole city without passing "radius" parameter? Because I don't know radius of each city :) Documentation says "Searches can be done near a point or through a whole city", but how can I provide this in venues/search?
Thanks.
I do not think there is a way to tell it 'search the entire city', but I also think it might be a wrong use case.
You need to remember a few things when searching:
Foursquare will return up to 50 results (the limit parameter)
The 50 results are ordered by the most popular places around the center of your search
So if you are searching a city which have more than 50 venues in Foursquare database, 'searching the entire city' will usually get the same (up to) 50 results - always.
This where the filters comes in handy, in our case, to get you better results for our needs, we use the categoryId combined with the radius to get things we want to show our users. Sometimes we get information from other cities because of a big radius, but for our application its okay, we actually give our customers more options :) . I can also guess that a lot of apps also use the query filter as they know the name of the place they are looking for.
You just need to experiment with it and discover how to get the data which is right to your application.
In theory, to search an entire city I would use the city lat/lng from Google or Open Street Maps or geonames and do a 10Km search around that point (intent=browse, radius=10000), the following is a guess, but it will get 50 places for over 99% of the cities people who own smartphones live in :)
You can do obtain results within in a city as follows:
https://api.foursquare.com/v2/venues/search?near=Singapore,Singapore&client_id=YOUR_CLIENT_ID
&client_secret=YOUR_CLIENT_SECRET3&v=YYYYMMDD
For more details check the documentation:
https://developer.foursquare.com/docs/venues/explore
Assuming you're talking about requests with a query, I would just set a reasonable value for radius and use the city's default city center. If you want to avoid showing results from neighboring cities, you can post-request filter by the returned venue's "city" string in the location stanza.
I'm getting some erratic results from Foursquare's venue search API and I'm wondering if anyone has any tips on how to process my input parameters for the most "intuitive" results.
For example, suppose I am searching for a venue called "Ise Sushi", around "New York, NY", which is equivalent to (lat: 40.7143528, lon: -74.00597309999999) using Google Maps API. Plugging into the Foursquare Venue API, we get:
https://api.foursquare.com/v2/venues/search?query=ise%20sushi&ll=40.7143528%2C-74.00597309999999
This yields pretty underwhelming results: the venue I'm looking for ends up rather far down the list, at 11th place. What's interesting is that reducing the precision of the coordinates appears to produce much better results. For example, suppose we were to round the coordinates to 3 significant digits:
https://api.foursquare.com/v2/venues/search?query=ise%20sushi&ll=40.7%2C-74.0
This time, the venue I'm looking for ends up in 2nd place, even though it is actually farther from the center of the search (1072 meters, vs. 833 meters using the first query).
Another modification that appears to help improve the quality of search is substituting underscores for spaces to separate our search terms. For example, here's the original query with underscores:
https://api.foursquare.com/v2/venues/search?query=ise_sushi&ll=40.7143528%2C-74.00597309999999
This produces the most intuitive-seeming results: the venue I'm looking for appears first, and is accompanied by just one other result, "Ise Restaurant" (which is tagged as a "sushi restaurant"). For what it's worth, this actually seems to be the result set of the same search conducted on Foursquare's own website.
I'm curious what lessons I should be learning from this. Should I be reducing the precision of my coordinates? Should I be connecting my search terms with underscores, and if so, does that limit how a user can order their search terms?
Although there are ranking improvements we can make on our end to find this distant exact match, it generally also helps to specify intent=browse (although it looks like in this case, for now, it may give you worse results). By default, /venues/search uses intent=checkin, which tries really hard to find close-by matches for checking in to, at the expense of other ways a venue might match your search. Learn more at https://developer.foursquare.com/docs/venues/search
i want to query Venue Tips for specific keywords at a larger distance. currently when i do a query the distance is usually between 40-80 kilometers, however if i wanted to calculate a whole country I'd have to do multiple queries.
I've been singling out a particularly created by me in my hometown and adapting the lat and long coordinates, (+/- 40-80 Kilometers) it looks like the distance radius is not uniform, some kind of clusters fundamental to the foursquare data structure.
if i wanted to do a complete search for a country i'd have to define multiple points and hope that i include all of the desired area, also if the the resultset is larger than 500 i'd have to again divide the area to get results on a more granular basis.
my question basically is whether my approach is right or for anyone to provide additional hints
thx in advance.
There's no way to search tips in that large of a area at the moment. That being said, the foursquare venue search behavior is constantly evolving so it's not inconceivable that a larger radius may someday be supported.
If you're building a user application, maybe you can show them a map and let them drag a pin around which then recenters where they're searching.
The maximum supported radius is currently 100,000 meters. That's already a bit more than the 40-80 kilometers you mentioned.