elasticsearch-net icon indicating copy to clipboard operation
elasticsearch-net copied to clipboard

Deserializing multi search response using `RequestResponseSerializer` throws an exception

Open gilmatok opened this issue 1 year ago • 2 comments

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:

  1. Build a multisearch body as documented in Elasticsearch docs.
  2. Using the low-level client, send a request to the multisearch API:
var response = await _client.LowLevel.MultiSearchAsync<StringResponse>(indexName, PostData.String(body));
  1. Given the response is succesful, try to deserialize the response body as MultisearchResponse using the RequestResponseSerializer:
var serializedResponse = _client.RequestResponseSerializer.Deserialize<MultiSearchResponse>(new MemoryStream(System.Text.Encoding.UTF8.GetBytes(response.Body)));
  1. An exception of type MissingMethodException will be thrown.

Expected behavior The response should be serialized without any issues.

gilmatok avatar Jun 07 '23 15:06 gilmatok

@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 avatar Jun 29 '23 08:06 stevejgordon

@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).

gilmatok avatar Jun 29 '23 08:06 gilmatok