Google Places API allows me to get the ratings for a place like so:
https://maps.googleapis.com/maps/api/place/details/json?placeid=<>&key=<>
It then returns the overall rating for the place like so:
...
"result" : {
"vicinity" : "...",
"rating" : 3.7,
"user_ratings_total" : 49
...
Is it possible to get each rating with date time also? Not just the aggregated value.
Yes. Check out this Placeid:
https://maps.googleapis.com/maps/api/place/details/json?placeid=ChIJOWSLUlcJ9YgR5Uxn4sbjYGk&key=<>
Here's a sample. Notice the "Time" tag:
{
"aspects" : [
{
"rating" : 3,
"type" : "overall"
}
],
"author_name" : "Michaela O'Neal",
"author_url" : "https://plus.google.com/105457747713750328544",
"language" : "en",
"rating" : 5,
"text" : "Love to go here for breakfast! They have amazing croissants and there are definitely many choices to pick from! We always had a really nice server and if it's nice weather outside they have a cute patio. It might get a little too loud inside during weekends. ",
"time" : 1401332428
},
{
"aspects" : [
{
"rating" : 3,
"type" : "overall"
}
],
"author_name" : "Myles Rothacker",
"author_url" : "https://plus.google.com/115555770858439445523",
"language" : "en",
"rating" : 5,
"text" : "I love the Eggs Benedict. Dollar the waiter is great.. I go in about 2 times a month have a few business meetings he is always at the top of his game. Timing when to refill, not interrupting and waiting until we are done to give me the check. This is a great place to have a morning meeting or a casual brunch. ",
"time" : 1375492655
}
Related
is it possible to perform Completion on Elasticsearch and get result even if text is from the middle of input?
For instance:
"TitleSuggest" : {
"type" : "completion",
"index_analyzer" : "simple",
"search_analyzer" : "simple",
"payloads" : true,
"preserve_position_increments" : false,
"preserve_separators" : false
}
That's my current mapping and my query is
{
"passport": {
"text": "Industry Overview",
"completion": {
"field": "TitleSuggest",
"fuzzy": {
"edit_distance": 2
}
}
}
}
But nothing is returned, I have documents that contain Industry Overview in their input. For instance if I'm looking only for Industry:
{
"text" : "Industry",
"offset" : 0,
"length" : 8,
"options" : [{
"text" : "Airline Industry Sees Recovery in 2014",
"score" : 16
}, {
"text" : "Alcoholic Drinks Industry Overview",
"score" : 16
}, {
"text" : "Challenges in the Pet Care Industry For 2014",
"score" : 16
}
]
}
I can achieve that by using nGrams, but I'd like to get this done using completion suggesters
So my initial goal would getting this if I type in Industry Overview
{
"text" : "Industry Overview",
"offset" : 0,
"length" : 8,
"options" : [{
"text" : "Alcoholic Drinks Industry Overview",
"score" : 16
}
]
}
I've tried using shingle analyzer - that didn't solve the problem and I didn't come up on Google with anything useful.
ES Version : 1.5.1
Here is a query that I believe should produces hotel with the same name very closed to the reference point.
https://maps.googleapis.com/maps/api/place/textsearch/xml?key=_your_api_key_goes_in_here_&sensor=false&language=en&location=56.1995,-4.746&radius=30000&query=ARROCHAR
As yo can see the location is 56.1995,-4.746. This is a place in UK. The query if for a hotel named Arrochar. The hotel does exist. The result look like this :
{
"html_attributions" : [],
"results" : [
{
"formatted_address" : "Arrochar, Staten Island, NY, USA",
"geometry" : {
"location" : {
"lat" : 40.59234250,
"lng" : -74.07407289999999
},
"viewport" : {
"northeast" : {
"lat" : 40.60012790,
"lng" : -74.05918419999999
},
"southwest" : {
"lat" : 40.5779020,
"lng" : -74.08570610
}
}
},
"icon" : "http://maps.gstatic.com/mapfiles/place_api/icons/geocode-71.png",
"id" : "c7d9f74dca8676759bfe7ea168b8547cd6de3c5e",
"name" : "Arrochar",
"reference" : "CpQBiAAAAKYklx4_uV5ovlJP-x-fGr2VAqzhUCRQ2icNBXj2b5TkGZMqix3tL4xyTizwa0_UdZ5VDbI3psEagu0tTiFc2N6Awn2OJE4Oc3NXtXyaUlADLhJKwnZSuMFLFv85ia3AKiR9fFVWH96u6lEcC16foKMyFREY_KR6Z97QdShfiJCPYNlYZye49gsdU0UsIx3YbxIQa5LUZiMGZvW8sQHn_Cog-hoUr4bMXlYdo9Xae82ZRL-BEDSKRAw",
"types" : [ "neighborhood", "political" ]
}
],
"status" : "OK"
}
As one can see this place is in US and it is more than 5000 km away. Now, if one goes and modifies the query too look like this:
https://maps.googleapis.com/maps/api/place/textsearch/xml?key=_your_api_key_goes_in_here_&sensor=false&language=en&location=56.1995,-4.746&radius=30000&query=hotel+ARROCHAR
Then the correct result appear:
{
"formatted_address" : "Main Street, Arrochar, United Kingdom",
"geometry" : {
"location" : {
"lat" : 56.199560,
"lng" : -4.7459760
}
},
"icon" : "http://maps.gstatic.com/mapfiles/place_api/icons/lodging-71.png",
"id" : "78d53766dfb2c3bb6008301b079423fffb78b801",
"name" : "Arrochar Hotel",
"reference" : "CnRtAAAAJPg2ABkegIT9Q12hABjfGezwGgHCc3ur1W761rhtkQq0n6Id-cgaLREU-g8Uo5Bnw4ovaAnqCrYm_fHEKjBHOrHK5dvcGpAndQVsl-zi_qZSZR6Sa5HvYZI4pA3ne3rNTl0m4TwuwmMM0nx2gSkxEBIQFqgW85GrUZI8SQFvohgMiBoU51C716M4m-ySUVECgT4BFZUYB50",
"types" : [ "lodging", "establishment" ]
}
So why is Places API text search acting like that? Note, the location parameter point to the exact place where the hotel is. Yet, I get something that is 5000 km away, unless I add the word 'hotel'.
Thanks
This is pretty old but just in case, I believe you should use nearbysearch instead of textsearch. (In your url)
Based on Google Places API documentation, your search has nothing to do with an specific location/distance.
Take into account that by using 'nearby search,' location and radius are required parameters. 'textsearch' just requires query and key.
Note: Radius might be required not to be included if using rankby=distance. Check the documentation for more details.
Good luck.
I have developed a script to fetch and show google reviews using google places api.
It fetches five reviews but not the latest.
Does google places api returns 5 random reviews or latest 5 reviews ?
Thanks
as stated here : http://code.google.com/p/gmaps-api-issues/issues/detail?id=2477
"It's the top 5 reviews shown on Google+ Local, which I believe are ranked by relevance/helpfulness. It's not possible to change the set of reviews that are requested."
Places API only returns 5 by default, if you apply for the GMB API and you manage verifies locations you can access the reviews on the account but this only works if you’re approved for the API and you authenticate to the business; alternatively you can always copy/paste or use a third-party service to fetch like Reviewsmaker; but there’s no other way of getting more than 5 returned with Places API, same thing with Yelp who also restricts you from fetching more than a capped number.
Simply you have an api that will always return the latest reviews from google map location.
https://maps.googleapis.com/maps/api/place/details/json?place_id={Your Place ID}&fields=name,rating,reviews&key={GOOGLE DEV KEY}
Here is the response from that api.
{
"html_attributions" : [],
"result" : {
"name" : "gathern app",
"rating" : 5,
"reviews" : [
{
"author_name" : "صالح وحيد Saleh Waheed",
"author_url" : "https://www.google.com/maps/contrib/100946881376925963940/reviews",
"language" : "en",
"profile_photo_url" : "https://lh3.ggpht.com/-bgNhUmU_Ftg/AAAAAAAAAAI/AAAAAAAAAAA/-rLGfz7aAEk/s128-c0x00000000-cc-rp-mo-ba2/photo.jpg",
"rating" : 5,
"relative_time_description" : "in the last week",
"text" : "Gathern is an online platform that helps people find vacation rentals and chalets in KSA.\n\nGreat team and great website.\n\nGathern.co",
"time" : 1582015365
},
{
"author_name" : "Hassan Raza",
"author_url" : "https://www.google.com/maps/contrib/109666951306307815476/reviews",
"language" : "en",
"profile_photo_url" : "https://lh3.ggpht.com/-VrVSfhsRo28/AAAAAAAAAAI/AAAAAAAAAAA/9gJQWSdJ3TM/s128-c0x00000000-cc-rp-mo-ba3/photo.jpg",
"rating" : 5,
"relative_time_description" : "a week ago",
"text" : "Great peoples and superb platform for booking online chalets.",
"time" : 1581492666
},
{
"author_name" : "Eman Alswailem",
"author_url" : "https://www.google.com/maps/contrib/115734038039879616345/reviews",
"language" : "ar",
"profile_photo_url" : "https://lh4.ggpht.com/-xNiMOs2bD3A/AAAAAAAAAAI/AAAAAAAAAAA/tElDIT5zP78/s128-c0x00000000-cc-rp-mo/photo.jpg",
"rating" : 5,
"relative_time_description" : "2 months ago",
"text" : "تطبيق ممتاز لحجز الشاليهات اون لاين",
"time" : 1575659218
},
{
"author_name" : "Hanan alnami",
"author_url" : "https://www.google.com/maps/contrib/114513293972924581219/reviews",
"language" : "ar",
"profile_photo_url" : "https://lh6.ggpht.com/-BUEZWeWQhv4/AAAAAAAAAAI/AAAAAAAAAAA/7A8id3FGLQA/s128-c0x00000000-cc-rp-mo/photo.jpg",
"rating" : 5,
"relative_time_description" : "6 months ago",
"text" : "تطبيق ممتاز دايم احجز منه شاليهات شكرا لكم",
"time" : 1566223757
}
]
},
"status" : "OK"
}
I'm trying to do a query via the Places API to find places related to the term wakeboards near Washington, DC. However, the results I'm getting back show law firms. Here's the query I'm making:
https://maps.googleapis.com/maps/api/place/search/json?location=38.897244,-77.0413344&sensor=false&radius=5000&keyword=wakeboards&key=XXXYYYZZZ
And, here is the result that I'm getting...
{ "html_attributions" : [], "results" : [
{
"geometry" : {
"location" : {
"lat" : 38.9088260,
"lng" : -77.04382099999999
}
},
"icon" : "http://maps.gstatic.com/mapfiles/place_api/icons/generic_business-71.png",
"id" : "54ebf52e053beb9b3f4d8c753975571eb532a8d7",
"name" : "Marshfield Associates",
"reference" : "snip",
"types" : [ "finance", "establishment" ],
"vicinity" : "21 Dupont Cir NW # 500, Washington"
},
{
"geometry" : {
"location" : {
"lat" : 38.8932170,
"lng" : -77.02048499999999
}
},
"icon" : "http://maps.gstatic.com/mapfiles/place_api/icons/generic_business-71.png",
"id" : "82d45a91169dda03932d8cba1cbb66007ce985ef",
"name" : "Gravitas Capital Advisors",
"reference" : "snip",
"types" : [ "finance", "establishment" ],
"vicinity" : "601 Pennsylvania Ave NW, Washington"
},
{
"geometry" : {
"location" : {
"lat" : 38.9195570,
"lng" : -77.027940
}
},
"icon" : "http://maps.gstatic.com/mapfiles/place_api/icons/generic_business-71.png",
"id" : "dba09f9090c092573b8c4ab0de10b8d2ac921e3e",
"name" : "Casa Iris",
"reference" :"shortersnip",
"types" : [ "establishment" ],
"vicinity" : "2201 12th Street Northwest, Washington"
} ], "status" : "OK" }
Clearly "Marshfield Associates" doesn't sell wakeboards. So, what am I doing wrong in this query? I have also tried it via a third party API/wrapper, and it returns the same results.
Thanks for any help you can provide.
P.s. sorry for the crappy formatting of the json response. Not sure how to get it to wrap nicely in SO.
The easy solution to this problem is to go to Google Maps, insert your location (38.897244,-77.0413344) and then "search nearby" for wakeboards manually. The full search results on the website usually draw attention to the exact match.
I did so and my results suggest that Marshfield Associates is coming up because findthebest.com is keyword spamming on their business listings and "wakeboards" happened to be one of the keywords spammed on that page. Unfortunately, false positives like this are common on Google Maps, because location is weighted so heavily -- on a normal web search, keyword spam like this wouldn't even make the top 1000.
The other obvious false positives are also on findthebest.com with exactly the same keyword spam text (which is rather unusual and may point to a technical malfunction on the part of that site). Here's a link that should go to the exact search I'm looking at: http://g.co/maps/2ny2p see H, I and J.
I need to create a map/array for auto complete from a JSON response and I am looking for the best, most efficient way to do it in Ruby and Rails 3. A portion of the response is below and the working code I have is before it. What is the one line of code I need to create locations for me?
# Need help making this more efficient
response_fields = JSON.parse(response.body)
predictions = response_fields['predictions']
predictions.each do |prediction|
locations << prediction['description']
end
Sample response from API:
{
"predictions" : [
{
"description" : "Napa, CA, United States",
"id" : "cf268f9fb9a1b46aed72d59ab85ed40f982763c6",
"matched_substrings" : [
{
"length" : 4,
"offset" : 0
}
],
"reference" : "CjQvAAAAqZWNGzqtJf3awNuQNQdnZpl4dBVVXFPrPdz29r1jo1GMWYFuz3KRlK9HgdgszOThEhDeYz_vYgcOPJTaYehF11bUGhR8yH9zqMGV9kenZIo9OTBrSwftgg",
"terms" : [
{
"offset" : 0,
"value" : "Napa"
},
{
"offset" : 6,
"value" : "CA"
},
{
"offset" : 10,
"value" : "United States"
}
],
"types" : [ "locality", "political", "geocode" ]
},
You can shorten your code like this:
locations = JSON.parse(response.body)['predictions'].map { |p| p['description'] }