Support Questions
Find answers, ask questions, and share your expertise
Announcements
Alert: Welcome to the Unified Cloudera Community. Former HCC members be sure to read and learn how to activate your account here.

Ingest google map search item ratings

Highlighted

Ingest google map search item ratings

New Contributor

I have a few google map search contexts like "restaurant name" or restaurants for cuisine like "mexican" and need to extract each restaurant in that list name and user ratings (overall rating and individual rating) into hadoop. Can anyone help me with what google API will expose that public data for consumption?

1 REPLY 1

Re: Ingest google map search item ratings

@Hary Tadi

You should make a web request to a URL similar to this: https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=35.7796,-78.6382&radius=500&ty...

Note: Make sure you insert your own Google Places API key.

This is using the Google Places API (I'm targeting restaurants in the Raleigh, NC area). Here's what the json response will look like:

{
   "html_attributions" : [],
   "results" : [
      {
         "geometry" : {
            "location" : {
               "lat" : 35.7781669,
               "lng" : -78.640547
            },
            "viewport" : {
               "northeast" : {
                  "lat" : 35.7783907,
                  "lng" : -78.6405374
               },
               "southwest" : {
                  "lat" : 35.7780923,
                  "lng" : -78.64055020000001
               }
            }
         },
         "icon" : "https://maps.gstatic.com/mapfiles/place_api/icons/restaurant-71.png",
         "id" : "0b6af460338b6684ebdfb2e9ab166228096a18e1",
         "name" : "Death and Taxes",
         "opening_hours" : {
            "exceptional_date" : [],
            "open_now" : false,
            "weekday_text" : []
         },
         "photos" : [
            {
               "height" : 1519,
               "html_attributions" : [
                  "\u003ca href=\"https://maps.google.com/maps/contrib/112671686149584704404/photos\"\u003eDeath and Taxes\u003c/a\u003e"
               ],
               "photo_reference" : "CoQBdwAAAMCFWj4H8N2nWccPO9wp43h0ZY1MZPtMZbJH_LECDD_tZ2IzLHuFfux3wnd_cFjvgoe_OsUZFz60jcCXLUisaJ5NppdbNMMKGrKJA3fB3PnwaXWzYMc0Vu8w8vL756x3SPSpeHuwon0El6U4Qo913cj_Y7z2s6ZxjH-Ioa20Ojq4EhCw2ZnBG15V6qdIDS7Zb1P5GhS06Ty9AYU7rADFtglQ1EIqpsyZBg",
               "width" : 1519
            }
         ],
         "place_id" : "ChIJEyImA25frIkRsIhJGErQbQc",
         "rating" : 4.3,
         "reference" : "CmRRAAAAzfKCDeADWguDAhYAQ9AvF4w2h8emOk71ejJBwaCDleUApKet0RYvvp_izUYNedZGPAQiJTTjtPNJp5l6WP_kfl3nHd0e9XfNnQ-XvdUlw4G_khQ4cjaQCs2GnlpOwj6AEhCJNKr1l3sfdq53PGQ5CTH5GhTDxjJLF1NQ7Xk8B2jVO-uZZn-U3A",
         "scope" : "GOOGLE",
         "types" : [ "restaurant", "food", "point_of_interest", "establishment" ],
         "vicinity" : "105 West Hargett Street, Raleigh"
      },
      {
         "geometry" : {
            "location" : {
               "lat" : 35.7780598,
               "lng" : -78.63677629999999
            },
            "viewport" : {
               "northeast" : {
                  "lat" : 35.7782437,
                  "lng" : -78.63676565
               },
               "southwest" : {
                  "lat" : 35.7779985,
                  "lng" : -78.63677985
               }
            }
         },
         "icon" : "https://maps.gstatic.com/mapfiles/place_api/icons/restaurant-71.png",
         "id" : "50f2ded33ca34d9e0960e8a38c020ada2274b981",
         "name" : "Caffe Luna",
         "opening_hours" : {
            "exceptional_date" : [],
            "open_now" : true,
            "weekday_text" : []
         },
         "photos" : [
            {
               "height" : 2988,
               "html_attributions" : [
                  "\u003ca href=\"https://maps.google.com/maps/contrib/117733338662226365021/photos\"\u003eHannah Cho\u003c/a\u003e"
               ],
               "photo_reference" : "CoQBdwAAAFqcPUfCtPeFyDjoujMX2rbs2BDKh50PMl5urofk1Bj5xRWGvJa9farsbLchr4kFGhuVf-m0CtJkGiJDuavBPPP_KRcms_ly532O2w-8ifwTbi3nZZSt9XPtMyfDittQe10MjoioDEbSNLULzBhPf7ENv5KjWyUTzJwA9teH_3U6EhDFlbSCjW4QGPWd0yLs0cl0GhQfKi5lUuiG_ALM50BR1lAdSUsAqA",
               "width" : 5312
            }
         ],
         "place_id" : "ChIJi42jeW1frIkR_kp3cwgWp0g",
         "price_level" : 2,
         "rating" : 4.3,
         "reference" : "CmRRAAAAbta6x-fEFyPpkq3E9l-UrlDuVmgSrafwL99qrt5Vz6fPhDI9HIRyfW1QHUoy9TQk_1_raVJhpE0SGU118UolB_0emPuTB-mx-DY4S7yaY7July-0og5BmbpLk0XK_YnAEhDCa6YrbvyYmpnzDG2PYpAKGhQTJ5ls-c7IJu6niyz7x9EMW5JsAA",
         "scope" : "GOOGLE",
         "types" : [ "restaurant", "food", "point_of_interest", "establishment" ],
         "vicinity" : "136 East Hargett Street, Raleigh"
      },
      {
         "geometry" : {
            "location" : {
               "lat" : 35.7783858,
               "lng" : -78.6380794
            },
            "viewport" : {
               "northeast" : {
                  "lat" : 35.77839010000001,
                  "lng" : -78.63800795
               },
               "southwest" : {
                  "lat" : 35.77837290000001,
                  "lng" : -78.63829375
               }
            }
         },
         "icon" : "https://maps.gstatic.com/mapfiles/place_api/icons/restaurant-71.png",
         "id" : "42e66c9ac59d357fefb739dcf600ad6da6cfa674",
         "name" : "Sitti",
         "opening_hours" : {
            "exceptional_date" : [],
            "open_now" : true,
            "weekday_text" : []
         },
         "photos" : [
            {
               "height" : 4008,
               "html_attributions" : [
                  "\u003ca href=\"https://maps.google.com/maps/contrib/113871826378884549564/photos\"\u003eRCL Rekman\u003c/a\u003e"
               ],
               "photo_reference" : "CoQBdwAAADneighCJvgiyqO42i_SiktzOehS5ONG-7vKuzMqcetSQDAYTOr1P0ky6A1itMs2NyGE7FSrx4dGv4nSqW0q5LCwMjlhLRassFZ8iZDAmzDiW3QDFNrcaQLZK9UzkgzxQbTD3WTpCYWNNPwmirSUQhJYXM_3wUHW-AgKH2UerhizEhAhdFeCNsYrSdiErAZ3llQFGhSXS6H0smm0FOLhSGpC_QKOYZ2keg",
               "width" : 5344
            }
         ],
         "place_id" : "ChIJ19sFjm1frIkRfg9-b_kFExU",
         "price_level" : 2,
         "rating" : 4.4,
         "reference" : "CmRRAAAALD24ysCM_17vFWcKgBEGHUf3vdC0wsnSgpDlNEiuvMg-ElyEXTuGdi_cwdxwLGWrsc2aMUgeSsWpeuuAC3ID-JB7QxpEiLilyeVHnXXLQsAXDCmoznzr_mQQsHI_bCmBEhDW-4Q7XecJsjfHcFg7dFU-GhQmGfy2blho8-skejER2E5nD8IzPQ",
         "scope" : "GOOGLE",
         "types" : [ "bar", "restaurant", "food", "point_of_interest", "establishment" ],
         "vicinity" : "137 South Wilmington Street, Raleigh"
      },

Once you have the results, you'll need to use a tool to parse the JSON. I suggest that you use Hortonworks DataFlow (specifically Apache NiFi) to make the web request as well as for parsing the JSON. Then, you can write the data to HDFS, Hive, or where ever you'd like.

More info on the Google API, found here: https://developers.google.com/places/web-service/search

Here's a few nifi examples to get you started: https://cwiki.apache.org/confluence/display/NIFI/Example+Dataflow+Templates. I'd suggest looking at Pull_from_Twitter_Garden_Hose.xml and InvokeHttp_And_Route_Original_On_Status.xml

Hope this helps!

Don't have an account?
Coming from Hortonworks? Activate your account here