Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ignore property with ElasticsearchClientSettings.DefaultMappingFor<>

Migrating from Nest to Elasticsearch V8

Before (using Nest) I had

var settings = new ConnectionSettings(new Uri(elasticSettings.Uri));
settings
    .ThrowExceptions(elasticSettings.ThrowExceptions)
    .PrettyJson(elasticSettings.PrettyJson)
    .DefaultMappingFor<CorrelationContext>(ms => ms.Ignore(p => p.DgpHeader));

Changed ConnectionSettings to ElasticsearchClientSettings but the Ignore-option on DefaultMappingFor isn't available anymore. I only find documentation regarding this for v7 but not for v8

Is it moved to somewhere else? And if not, how can we achieve the same result?

Update: After looking further in the documentation I came across the page regarding serialization. However, I do not have access to the class-code to add the JsonIgnore attribute (class is in other library).

like image 998
Koen Avatar asked Dec 29 '25 09:12

Koen


1 Answers

Couldn't find way to do it through settings so ended up creating a new POCO with the exact same name and properties as the original class (obviously without the one property I want to ignore).

like image 131
Koen Avatar answered Jan 01 '26 03:01

Koen



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!