Title: Google Places JS: Exact Match
Tags: javascript;google-places-api
Question: i'm using google places to find nearby places by type, for example:

```placeService.nearbySearch({
  location: {
    lat: lat,
    lng: lng
  },
  radius: radius,
  type: 'hospital'
});
```

This query return also private clinics that i don't want to include in my results.
I tried using the parameter "name" with "hospital" but no luck.
How can i limit the query to search only for hospitals (strict meaning)

Response example (the first one is the clinic):

```[
  {
    "geometry": {
      "location": {
        "lat": lat,
        "lng": lng
      }
    },
    "icon": "https://maps.gstatic.com/mapfiles/place_api/icons/generic_business-71.png",
    "id": "b5999bf0dd4430fb9727d646124786d65d9b3598",
    "name": "Private Clinic",
    "opening_hours": {
      "open_now": true,
      "weekday_text": []
    },
    "place_id": "ChIJddQneTymMRMRv2A_Sl2z6Pk",
    "reference": "CmRSAAAAL92d4D0kBQ6OBL-S7sNok47bUoJrW0fBRpfvfOwQMH6lLY7qYFT6TsCfOonjjM8Ga5McGz10-sxpVNOO_a3llvkUE98ny_xaVPKs46hyQuld_GwqWQQ5FcGc6XMj1_eOEhCQn0JPeNTi8cQHLjnxe3xSGhQAI18uipgHZyx-myoOjCRYMMEfmw",
    "scope": "GOOGLE",
    "types": [
      "hospital",
      "doctor",
      "health",
      "point_of_interest",
      "establishment"
    ],
    "vicinity": "Address",
    "html_attributions": []
  },
  {
    "geometry": {
      "location": {
        "lat": lat,
        "lng": lng
      }
    },
    "icon": "https://maps.gstatic.com/mapfiles/place_api/icons/doctor-71.png",
    "id": "ff2075175d3d83fff78113c06029e8ead3b4b1a5",
    "name": "Hospital",
    "opening_hours": {
      "open_now": true,
      "weekday_text": []
    },
    "place_id": "ChIJHU7OI-ClMRMR4n9sWIPONLw",
    "rating": 3.7,
    "reference": "CmRSAAAA5J6mz42nH9AZX8hkst-Yh8XTLkb6jD54yWoUYTEnL0t47aWnJKTdop4qmRz2pO71OrtVmx_4mRxVQnezzy-uqx--82qKrTHQ0O2rK0BzbItwiHx8aUEp--EqLfEGQDYoEhA4jyOlEAwD2GJjkP21UbzhGhT1Te6iOF0nbcgWgMeZpIfEd1SC0Q",
    "scope": "GOOGLE",
    "types": [
      "hospital",
      "point_of_interest",
      "establishment"
    ],
    "vicinity": "Address",
    "html_attributions": []
  }
]
```

Comment: You need to filter the results yourself. Post a comprehensive sample of the results if you want help filtering them.

Comment: How does the term "privacy" apply to publicly available address entries for public institutions/companies? Besides, you wanted a way to filter by name, maybe taking out the names wasn't the best idea. ;)

Comment: Anyway, what you want to look into is the `Array#filter` method. Try things like *"filter the result array for items with `"Hospital"` in their name"*. Or *"filter the result array for items that do not have `"doctor"` as one of their categories"*. Maybe the latter is more resilient than the former. It all comes down to how consistent Google's place data is.

Comment: It's impossible to help you since you don't show your current code. However, your question is no so much *"How can I do $thing with Google Maps?"* anyway. It's *"How do I filter down a list of objects in Javascript?"* and that question has been answered countless times on this site and elsewhere, have a look around.

Comment: Yeah, there seems to be no way to make Google pre-filter the results you want. You must refine the results yourself.

Comment: @Tomalak i've posted the example. The first one is the clinic that i don't want to include, the second one is a good match. I removed the name, address and location for privacy.

Comment: @Tomalak you're right but the filter by name is just a try that i've done.. i'm open to every suggestions.

Comment: @Tomalak uhm ok, i agree about the last one (i'm already applying a filter on the property "types", checking that the first position is "hospital" but i don't know if there is a more "robust" way to do it)

Comment: @Tomalak my question is about google places and how to query in a more accurate way. But it seems that there is no way to do it so i have to filter the response and "this" is about javascript, not my question :). Anyway, thanks for your time.



{'source': 'StackExchangeDataset', 'subset': 'stackoverflow.com', 'metadata': {'AnswerCount': 0, 'CommentCount': 9, 'ContentLicense': 'CC BY-SA 3.0', 'CreationDate': '2017:00:04/10/17', 'FavoriteCount': None, 'PostTypeId': 1, 'Tags': '<javascript><google-places-api>', 'Title': 'Google Places JS: Exact Match', 'ViewCount': 57, 'id': 43325264, 'user_AboutMe': None, 'user_AccountId': 6258715.0, 'user_DisplayName': 'Thodak', 'user_Reputation': 11.0, 'user_Views': 2.0, 'user_id': 4866522.0}}