Skip to content

InferMappingFor.Ignore for inherited property #2556

@Grastveit

Description

@Grastveit

NEST/Elasticsearch.Net version: 5.0.1 (and also in 2.4)

Elasticsearch version: 5.1.2

Description of the problem including expected versus actual behavior:

I'd like to ignore an inherited property without using attributes. InferMappingFor is the other option then, however I'm only able to ignore declared properties.

Steps to reproduce:

The snippet below makes a mapping with a single inheritedProp-field, instead of no fields, as I expected.

void Main()
{
	new ElasticClient(new ConnectionSettings(new Uri("http://localhost:9200"))
		.InferMappingFor<Foo>(i => i
			.Ignore(f => f.InheritedProp)
			.Ignore(f => f.DeclaredProp))
	).CreateIndex("fooindex", c => c.Settings(s => s.NumberOfShards(1).NumberOfReplicas(0))
		.Mappings(ms => ms.Map<Foo>(m => m.AutoMap()))
	);
}

public class FooBase
{
	public int InheritedProp { get; set; }
}

public class Foo : FooBase
{
	public int DeclaredProp { get; set; }
}

I also unsuccessfully tried InferMappingFor<FooBase>.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions