Places API with countries

I am trying to limit searches by country. If I use the search data below I get no results, but if remove the countries = ‘GB’ the search returns the correct result. I am trying to limit as the place search returns the wrong result if people put a county in the search so I want to limit strings ending in UK, England etc to the United Kingdom.

array(4) {
string(9) “ilminster”
string(2) “GB”
string(2) “GB”

string(9) “ilminster”


Hi @janetaubman,

can you share the full request (in curl for example)?

I tried with the exact same parameters you provided but cannot reproduce your results:

I am using your php client.

The code is as follows

        $countries  = 'GB';
        $url = '';
        if ( $action == 'geocode' ) {
											$data = ( array( 'query' => $text, 'language' => 'GB', 'hitsPerPage' => 1 ) );
							else {
											$data = ( array( 'query' => $text, 'language' => 'GB' , 'hitsPerPage' => 12 ) );
        if ($countries != '') { $data['countries'] = $countries;}
$client = new \AlgoliaSearch\Client("xxx", "xxx");
$places = $client->initPlaces(xxx', "xxx");

$message = $places->search($text,$data);

Alright, I think I isolated the issue.

$countries = 'GB';
$countries = 'gb';

This is a bug on our end, it shouldn’t be case sensitive. I will open an issue in the project.

Let me know if it solved your issue!

That fixed it. Can I just check does the language setting also need to be in lowercase?


Yes it must be lowercase as well. It seems to work because english is the default lang, but the behaviour is undefined.

1 Like