elasticsearch-net
elasticsearch-net copied to clipboard
Deserializing multi search response using `RequestResponseSerializer` throws an exception
NEST/Elasticsearch.Net version: 7.17.5
Elasticsearch version: 8.4.3
.NET runtime version: .NET 7
Operating system version: Linux
Description of the problem including expected versus actual behavior:
When trying to deserialize a low-level multi search response of type StringResponse
using the RequestResponseSerializer
, an error is thrown: Constructor on type 'Nest.MultiSearchResponseFormatter' not found.
.
Steps to reproduce:
- Build a multisearch body as documented in Elasticsearch docs.
- Using the low-level client, send a request to the multisearch API:
var response = await _client.LowLevel.MultiSearchAsync<StringResponse>(indexName, PostData.String(body));
- Given the response is succesful, try to deserialize the response body as
MultisearchResponse
using theRequestResponseSerializer
:
var serializedResponse = _client.RequestResponseSerializer.Deserialize<MultiSearchResponse>(new MemoryStream(System.Text.Encoding.UTF8.GetBytes(response.Body)));
- An exception of type
MissingMethodException
will be thrown.
Expected behavior The response should be serialized without any issues.
@gilmatok We'll need to investigate this scenario. Is there any reason you're not using the NEST client directly rather than low-level and then deserializing, which essentially repeats the work the high-level client does? Have you tested with the high-level client to see if you get the same outcome?
@stevejgordon Thanks for the follow-up. The high-level client works fine when deserializing Multisearch responses. The reason I'm using the low-level is client is because I'm using Elastiknn plugin which requires me to build the request body manually (also because we're using NEST 7 against an Elasticsearch 8 server so not all the types are available).