Hi!
I have updated NEST from 2.4.3 to 2.4.4 and .MultiSearch
calls began to throw UnexpectedElasticsearchClientException
. The issue appears only in v2.4.4 and I can't reproduce it in v2.4.3, v2.4.5 or v2.4.6. However, the issue isn't mentioned in release notes for 2.4.5 so it may be kind of accidental break that was accidentally fixed in v2.4.5. It would be great to know for sure if this error was completely fixed in v2.4.5 or not
So this is minimal code to reproduce the error. The essential conditions to reproduce the error is to build a query against interface with .Search<ITestDocument>()
and setting the actual type with .Type<>()
:
class Program
{
static void Main(string[] args)
{
var client = new ElasticClient(new Uri("http://localhost:9200"));
client.Index(new TestDocument {Id = "1"}, s => s.Index("testdoc"));
var r = client.MultiSearch(ms => ms.Search<ITestDocument>("f", s => s.MatchAll().Type<TestDocument>().Index("testdoc")));
}
}
public class TestDocument : ITestDocument
{
public string Id { get; set; }
}
public interface ITestDocument
{
}
And this is error message (complete message):
Unhandled Exception: Elasticsearch.Net.UnexpectedElasticsearchClientException: Object of type 'Nest.JsonNetSerializer' cannot be converted to type 'Newtonsoft.Json.JsonSerializer'. ---> System.ArgumentException: Object of type 'Nest.JsonNetSerializer' cannot be converted to type 'Newtonsoft.Json.JsonSerializer'.
at System.RuntimeType.TryChangeType(Object value, Binder binder, CultureInfo culture, Boolean needsSpecialCast)
at System.RuntimeType.CheckValue(Object value, Binder binder, CultureInfo culture, BindingFlags invokeAttr)
at System.Reflection.MethodBase.CheckArguments(Object[] parameters, Binder binder, BindingFlags invokeAttr, CultureInfo culture, Signature sig)
at System.Reflection.RuntimeMethodInfo.InvokeArgumentsCheck(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at Nest.MultiSearchResponseJsonConverter.ReadJson(JsonReader reader, Type objectType, Object existingValue, JsonSerializer serializer) in C:\code\elasticsearch-net\src\Nest\Search\MultiSearch\MultiSearchResponseJsonConverter.cs:line 67
...