Search Suggestion behaviour - Allow Region Search and not just limiting it to Regions with their corresponding Suburbs (but shouldn't be compromised)

I am trying to make my search suggestions provide users with an option to search based on Region so queried results are returned exactly for that Region without their corresponding suburbs which narrows down the search, like it behaves at the moment but shouldn’t be compromised. For instance the Region (Parent) -> “Greater Accra Region” has “Ashiaman, Madina, Tema, Accra, Teshie” as suburbs (children) but in some use cases i am just interested in querying the Region and not the suburbs under the respective Region in order to have a much broader search scope. Will it be possible to have an option to Select Region alongside the other suggestions returned to enable so the user can have results for everything under that region too?. Refer to Screenshot below.

The below API is what i am leveraging so far and does pretty much what i need it to do :slight_smile:

  (function () {
    var placesAutocomplete = places({
      appId: "xxx",
      apiKey: "xxx",
      container: document.querySelector("#keyword_search"),
    }).configure({
      countries: ["gh"],
    });
   var $address = document.querySelector("#single-country-address-value");
    placesAutocomplete.on("change", function (e) {
      var searchTerm = e.suggestion.name;
      var searchType = document.getElementById("_property_type").value;
      console.log(searchTerm, searchType);
      var url = `http://demo.ohmyproperty.com/properties/?realteo_order=featured&keyword_search=${searchTerm}&_property_type=${searchType}&_offer_type=&tax-region=&_bedrooms=&_bathrooms=&_area_min=0&_area_max=1000&_price_min=1&_price_max=5564045`;
      console.log(url);
      window.location.href = url;
      $address.textContent = e.suggestion.value;
    });
    placesAutocomplete.on("clear", function () {
      $address.textContent = "none";
    });
    var $country = document.querySelector("#country-selector");
    // $country.addEventListener("change", function (e) {
    placesAutocomplete.configure({ countries: ["gh"] });
    // });
  })();
</script>

I also came across these interesting search parameters here https://community.algolia.com/places/api-clients#api-suggestion-administrative but wasn’t too sure how to apply them, especially “administrative” which i think is close to what i was looking for. I was also thinking this could help with the order in which the suggestions were presented e.g Regions first in ranking then Suburbs https://community.algolia.com/places/examples.html#using-_rankinginfo but wasn’t sure on how to leverage. Some assistance will be appreciated.

Hi @johnzuh!

The administrative you see in the documentation is not a parameter that you can pass to a search, but a property the you have on results.
example here:
image

You can filter the type of results that the API will return, as you can see here, but unfortunately, administrative is not a type of result we provide with the places API.

1 Like

@emmanuel.krebs Thanks for the feedback. I will figure a workaround and hopefully this parameter will be considered in the near future.