This is related to a previous topic I raised: Elastic.Clients.Elasticsearch .NET client - calling Vector tile search API
I am attempting to update to the latest version of Elastic.Clients.Elasticsearch (v8.13.8).
As the SearchMvt now appears to be supported I can call it with proper typing and not have to use the low level client.
Here is my code
var result = await _elasticClientProvider.Client.SearchMvtAsync(
index, "geometry", zoom, x, y,
request =>
{
request.Query(boolQuery)
.Fields(fields)
.GridPrecision(0)
.TrackTotalHits(new TrackHits(false))
.RequestConfiguration(configuration => configuration
.ContentType("application/vnd.mapbox-vector-tile")
.Accept("application/vnd.elasticsearch+json"));
}, ct);
return result.ApiCallDetails.ResponseBodyInBytes;
Which returns an error with this message:
Unsuccessful (406) low level call on POST: /my-index/_mvt/geometry/2/0/1?pretty=true&error_trace=true
Exception: Request failed to execute. Call: Status code 406 from: POST /my-index/_mvt/geometry/2/0/1?pretty=true&error_trace=true. ServerError: Type: Reason: "Content-Type header [application/vnd.mapbox-vector-tile] is not supported"
Ok so I will reverse the settings, and use mapbox-vector-tile in the Accept header, like what happened in the previous topic:
.RequestConfiguration(configuration => configuration
.Accept("application/vnd.mapbox-vector-tile")
.ContentType("application/vnd.elasticsearch+json"));
# Audit exception in step 1 BadResponse:
System.Text.Json.JsonException: '0x1A' is an invalid start of a value. Path: $ | LineNumber: 0 | BytePositionInLine: 0.
---> System.Text.Json.JsonReaderException: '0x1A' is an invalid start of a value. LineNumber: 0 | BytePositionInLine: 0.
Which makes sense, as the JSON serializer wouldn't be able to read the returned binary.
However I can't set the Content-Type to "application/vnd.mapbox-vector-tile".
It always says not supported 406, like my first error.
Adding SearchMvtAsync<BytesResponse>
doesn't seem to do anything.
Assistance appreciated, thanks.