What's the best way to tune my Foursquare API search queries?
Asked Answered
C

1

13

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?

Chor answered 20/1, 2012 at 17:26 Comment(1)
Great question, this really should be answered by someone from Foursquare. One thing to notice, the lat/lng precision: I think that Foursquare truncate your lat/lng, because the sensors of smarphones are not accurate, anything after the ~4th, sometime 5th point is irrelevant. Do not know where Foursquare cut the numbers, but take in mind that they probably do. (btw, anything after the 6th or 7th point is also irrelevant for civilian gps, no matter what the source is)Osteo
A
1

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

Anglicist answered 23/1, 2012 at 16:46 Comment(2)
I tried intent=browse early on, but it didn't seem to produce a radical improvement. The Foursquare website's own search feature seems to produce reasonably intuitive results, so I'm curious how much of its internal structure it shares with the Venues API. Anyway, the tactic I'm using now is to start with the underscore-substituted query. If the number of results is less than a given limit, I'll re-query using the original search term (i.e., without substitutions). Through some admittedly limited testing, it seems to provide a good mix of results.Chor
Yeah, it would definitely be good to know how the foursquare website searches. I've tried a variety of methods to get accurate results and I've never been able to come close to the results on the website. Doesn't matter what intent I use, whether I use radius + a point, whether I use bounding boxes for the location, etc. Any chance of giving us some info on how the website is querying for places?Dispraise

© 2022 - 2024 — McMap. All rights reserved.