Skip to content

7.0.0 ElasticsearchTypeAttribute should continue to support Name property #3681

@nenadvicentic

Description

@nenadvicentic

NEST/Elasticsearch.Net version:
7.0.0-alpha1
Elasticsearch version:
7.0.0
Description of the problem including expected versus actual behavior:

Actual
Even though mapping types have been removed in Elasticsearch 7.x, option to set name of the class for serialization is still useful when using fluent/strongly-type interfaces.

  1. When defining Join in index mapping:
_client.CreateIndexAsync(IndexName,
    index => index.Map<MyDocument>(
        tmd => tmd.AutoMap()
        .Properties(
            props => props.Join(
                j => j.Name(p => p.Relationship)
                .Relations(
                    r => r.Join<ParentType, ChildType>()
                    )
                )
            )
        )
    );
  1. When linking instances of child types to parent types:
var parent = new ParentType { Id = 1 };
var parentDoc = new MyDocument
{
    Parent = parent,
    Relationship = JoinField.Root<ParentType>()
}

var childDoc = new MyDocument
{
    Child = new ChildType(),
    Relationship = JoinField.Link<ChildType>(new Id(parent.Id))
}
  1. When using JoinAttribute on JoinField property:
public class MyDocument
{
    public ParentType Parent { get; set; }

    public ChildType Child { get; set; }

    [Join(typeof(ParentType), typeof(ChildType))]
    public JoinField Relationship { get; set; }
}

Expected
Therefore, possibility to override class name for serialization should still be supported. In the past ElasticsearchTypeAttribute's Name property was used for this.

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