nxdomain errror when using AWS.Location.search_place_index_for_text
Closed this issue · 7 comments
The code in AWS.Request.build_host 1 (https://github.com/aws-beam/aws-elixir/blob/v0.12.0/lib/aws/request.ex#L165)
will produce a hostname like:
geo.eu-west-1.amazonaws.com
for these requests, but that host doesn’t exist
The Amazon documentation (https://docs.aws.amazon.com/location/latest/developerguide/location-regions.html)
says that the correct host for a place search in eu-west-1 is:
places.geo.eu-west-1.amazonaws.com,
which does resolve to an address.
My code:
client = AWS.Client.create(System.fetch_env!("AWS_ACCESS_KEY_ID"), System.fetch_env!
("AWS_SECRET_ACCESS_KEY"), "eu-west-1")
AWS.Location.search_place_index_for_text(client, "site_addresses", %{"Text" => "2 Water Lane"})
Response:
{:error, :nxdomain}
Conversation on elixir forum: https://elixirforum.com/t/aws-location-geocoding-returning-error/49755/2
Hi @shirawebill 👋
I'm going to take a look. This is probably something we are missing in the generator (aws-codegen).
@shirawebill would you mind to try with the version from this branch => ps-add-host-prefix-to-request
?
{:aws, github: "aws-beam/aws-elixir", branch: "ps-add-host-prefix-to-request"}
It should be fixed now.
If this passes for you, I should release a version with the fix.
Hi @philss
Thank you so much.
It does work for me; please see the below response:
iex(3)> AWS.Location.search_place_index_for_text(client, "site_addresses", %{"Text" => "2 Water Lane", "MaxResults" => "1"})
{:ok,
%{
"Results" => [
%{
"Place" => %{
"AddressNumber" => "2",
"Country" => "USA",
"Geometry" => %{"Point" => [-123.06759090347067, 44.13641645187638]},
"Interpolated" => true,
"Label" => "2 Water St, Eugene, OR, 97408, USA",
"Municipality" => "Eugene",
"PostalCode" => "97408",
"Region" => "Oregon",
"Street" => "Water St",
"SubRegion" => "Lane"
},
"Relevance" => 0.9711
}
],
"Summary" => %{
"DataSource" => "Esri",
"MaxResults" => 1,
"ResultBBox" => [-123.06759090347067, 44.13641645187638,
-123.06759090347067, 44.13641645187638],
"Text" => "2 Water Lane"
}
},
%{
body: "{\"Summary\":{\"Text\":\"2 Water Lane\",\"MaxResults\":1,\"ResultBBox\":[-123.06759090347067,44.13641645187638,-123.06759090347067,44.13641645187638],\"DataSource\":\"Esri\"},\"Results\":[{\"Place\":{\"Label\":\"2 Water St, Eugene, OR, 97408, USA\",\"Geometry\":{\"Point\":[-123.06759090347067,44.13641645187638]},\"AddressNumber\":\"2\",\"Street\":\"Water St\",\"Municipality\":\"Eugene\",\"SubRegion\":\"Lane\",\"Region\":\"Oregon\",\"Country\":\"USA\",\"PostalCode\":\"97408\",\"Interpolated\":true},\"Relevance\":0.9711}]}",
headers: [
{"Date", "Thu, 01 Sep 2022 06:46:47 GMT"},
{"Content-Type", "application/json"},
{"Content-Length", "468"},
{"Connection", "keep-alive"},
{"x-amzn-RequestId", "9bb0595c-5365-4162-bae6-98989f0f7101"},
{"Access-Control-Allow-Origin", "*"},
{"x-amz-apigw-id", "XxJFwEzvjoEFtZQ="},
{"Access-Control-Expose-Headers",
"x-amzn-errortype,x-amzn-requestid,x-amzn-errormessage,x-amzn-trace-id,x-amz-apigw-id,date"},
{"X-Amzn-Trace-Id", "Root=1-63105557-07197c521248ee8638905ee0"}
],
status_code: 200
}}
Cool!
I should probably release a new version with this later today.
I will let you know :)
@shirawebill A new version with the fix is released. It is v0.13.0
.Thank you for reporting this!
@philss thank you!!!