Yelp / yelp-api

Examples of code using our v2 API
http://yelp.com/developers
MIT License
580 stars 1.09k forks source link

Consult on location search api #168

Closed huidi7 closed 8 years ago

huidi7 commented 8 years ago

Hi,

I'm using yelp api for restaurant search. Could you please help to shed some lights on the following questions?

  1. What is the center location for a location search with radius_filter? For example, how is the center location selected for the following query? Is the center location the same as the one in the query response in region? Why this changes when i use a different radius_filter? https://api.yelp.com/v2/search/?term=coho&location=seattle&radius_filter=40000
  2. When I use a ll location during the query? Will this location be taken as the search center? https://api.yelp.com/v2/search/?term=coho&ll=47.6021513,-122.2849313&radius_filter=40000
  3. How could I specify the accuracy of the location? Could you please show me an example?

Thanks,

mittonk commented 8 years ago

@huidi7 ,

  1. When specifying search location using words, we geocode the string to find a location: https://en.wikipedia.org/wiki/Geocoding The "region" response shows the center and size of a good view of the results --- which is closely related to the search area, but not always the same. (If all the results are on the east side of town, the "region" will be centered around them, not the center of town.) For your example "seattle" query:
    "region": {
        "span": {
            "latitude_delta": 0.11800734735085427,
            "longitude_delta": 0.11127506533881615
        },
        "center": {
            "latitude": 47.611883296658704,
            "longitude": -122.335993324846
        }
    },

Could you show an example of this changing when you change radius_filter?

  1. As with "location" --- "ll" sets the center of the search area, "region" gives the best view of the results which might be slightly different. For your example "ll" query, I get:
"center": {
            "latitude": 47.6056773643747,
            "longitude": -122.22232894999999
        }

which is pretty close to the "ll" location, and shows the search results.

  1. When you say "accuracy", do you mean the "geo_accuracy" field in a business location? If so, you can't set that via Search --- it's a measure of how sure Yelp is of the business location. "8.0" means we have a street address, "4.5" means we only know the the city. See

    127 for some more details.

huidi7 commented 8 years ago

Thank you for your clarification @mittonk.

Another question on the sort rule for the search API: when I search McDonald's by distance, the returned result seems nothing to do with it.

For example, https://api.yelp.com/v2/search/?term=McDonalds&sort=1&ll=47.634832478669644,-122.04643455929276

huidi7 commented 8 years ago

If I search McDonald's by best matches, what is the ranking rule for the these items with same name as "McDonald's"?

mittonk commented 8 years ago

@huidi7 : Hm, the distance sort looks to be working for me for that search. Here's the URLs and distances I see:

{
    "region": {
        "span": {
            "latitude_delta": 0.06261309999999298,
            "longitude_delta": 0.11303551437529791
        },
        "center": {
            "latitude": 47.643390600000004,
            "longitude": -122.08496242073849
        }
    },
    "total": 40,
    "businesses": [
        {
...
            "url": "http://www.yelp.com/biz/mod-pizza-sammamish-4?adjust_creative=sWc_ig2aihT0s-6Yf-zGIQ&utm_campaign=yelp_api&utm_medium=api_v2_search&utm_source=sWc_ig2aihT0s-6Yf-zGIQ",
            "distance": 2274.4259784520195
        },
        {
...
            "url": "http://www.yelp.com/biz/mcdonalds-sammamish?adjust_creative=sWc_ig2aihT0s-6Yf-zGIQ&utm_campaign=yelp_api&utm_medium=api_v2_search&utm_source=sWc_ig2aihT0s-6Yf-zGIQ",
            "distance": 2342.5542354754707
        },
        {
...
            "url": "http://www.yelp.com/biz/whole-foods-market-redmond?adjust_creative=sWc_ig2aihT0s-6Yf-zGIQ&utm_campaign=yelp_api&utm_medium=api_v2_search&utm_source=sWc_ig2aihT0s-6Yf-zGIQ",
            "distance": 5148.3660172705395
        },
...

That's in nice distance order. If you're seeing something different, could you provide the output you see?

As to "Best Match": That looks at review content, name, and many other factors. It's not just a name match.

Does that answer your questions?

huidi7 commented 8 years ago

@mittonk yes, the distance order is right. I just wonder why the name of the first one is not "McDonald's" ? Or how can I get all the McDonald's ranked by distance?

"businesses": [ { "is_claimed": true, "rating": 3.5, "mobile_url": "http://m.yelp.com/biz/mod-pizza-sammamish-4?adjust_creative=7OM7gFZOwEDszaTgrAM8wg&utm_campaign=yelp_api&utm_medium=api_v2_search&utm_source=7OM7gFZOwEDszaTgrAM8wg", "rating_img_url": "https://s3-media1.fl.yelpcdn.com/assets/2/www/img/5ef3eb3cb162/ico/stars/v1/stars_3_half.png", "review_count": 43, "name": "MOD Pizza", ... "distance": 2274.4259784520195 },

mittonk commented 8 years ago

Yelp Search isn't a simple name lookup --- it takes into account review text and a variety of other signals.

If you're only looking for businesses named exactly "McDonald's", I'd suggest post-filtering the results.