Description
Elastic.Clients.Elasticsearch version:
8.18.2
Elasticsearch version:
8.18.2
.NET runtime version:
.NET SDK 9.0.301
Operating system version:
Windows 11 Pro 24H2
Description of the problem including expected versus actual behavior:
Updating Elastic.Clients.Elasticsearch
from 8.17.4 to 8.18.2 brings breaking changes in TypeMapping.DynamicTemplates
, see the diff here. If you adapt your code, then you'll get a "System.MissingMethodException: 'Constructor on type 'System.String' not found.'" exception from Elastic.Clients.Elasticsearch.Serialization.KeyValuePairConverterFactory
. I see no way of fixing this from the consumer code.
Steps to reproduce:
- Specify DynamicTemplates via
TypeMapping
for your index viaTypeMapping.DynamicTemplates.Add(new KeyValuePair<string, DynamicTemplate>("mypattern", template));
. This is buried down in the Elasticsearch feature of Orchard Core, but the concrete code we use is from here.l - Serialize the object for storage with
Elastic.Transport.Serializer
. Concrete code is here. - Deserialize the previously stored JSON with
Elastic.Transport.Serializer
. Concrete code is here. Observe that a "System.MissingMethodException: 'Constructor on type 'System.String' not found.'" exception is thrown fromElastic.Clients.Elasticsearch.Serialization.KeyValuePairConverterFactory
, see below. DynamicTemplates must be specified asKeyValuePair<string, DynamicTemplate>
, thus the keys must bestring
, andSystem.String
doesn't contain a constructor that takes astring
. So, I don't see this being possible to work around from the consumer code.
I realize this is far from a minimal repro, but if you need any other information, please let me know.
Expected behavior
No exception is thrown and deserialization completes, as it did on 8.17.4. BTW here are the code changes necessary between 8.17.4 and 8.18.0. These are BTW breaking changes, so I think they shouldn't have been released as a minor version.
Provide ConnectionSettings
(if relevant):
Not relevant.
Provide DebugInformation
(if relevant):
I don't think it's relevant.