'Elasticsearch - NEST - Creating mappings for types

I am using NEST for interacting with Elasticsearch. I am creating mappings for the types dynamically based on System.Type, using:

settings.DefaultMappingFor(type, d =>
{
    d.IndexName(indexName);
    d.IdProperty(idPropertyName);
    d.Ignore(prop1Name); // no such method
    return d;
}

I am not able to figure out how to ignore properties in the above snippet. From the docs I can see that we can ignore certain properties using the fluent api (with generics).

settings.DefaultMappingFor<MyObject>(d =>
{
    return d.IndexName("my-object")
        .IdProperty(x => x.ID)
        .Ignore(x => x.Prop1)
        .Ignore(x => x.Prop2);
});

But my need is to configure mappings dynamically. Please help, thanks!



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source