Elasticsearch - NEST - Creating mappings for types (.NET)

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!

Hi! Unfortunately, the non-generic mappings are more limited in this respect. Are you able to explain more about your situation? Would it be possible to apply the NEST Ignore attribute to the properties on the original Type as those should be picked up correctly?

1 Like

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.