How can I use nested types with NEST client for Elastic Search

后端 未结 1 1231
[愿得一人]
[愿得一人] 2021-01-03 11:44

I ran in to some issues whilst trying to use statistical facets on my documents in Elastic Search. This resulted in the following posts on the Elastic Search google group -

相关标签:
1条回答
  • 2021-01-03 12:11

    Try to map you object as followed:

    client.MapFluent<MyType>(m=>m
        .MapFromAttributes()
        .NestedObject<MyItem>(no=>no
            .Name(p=>p.MyItems.First())
            .Dynamic()
            .Enabled()
            .IncludeInAll()
            .IncludeInParent()
            .IncludeInRoot()
            .MapFromAttributes()
            .Path("full")
            .Properties(pprops => pprops
                .String(ps => ps
                    .Name(p => p.FirstName)
                    .Index(FieldIndexOption.not_analyzed)
                )
                //etcetera
            )
        )
    );
    

    The client.MapFromAttributes() is very limited and will probably be removed in the 1.0 release. Its great to annotate property names but quickly becomes limitted in what it can express. The MapFromAttributes() in the mapfluent call is still a great way to type int's as int, float's as floats, DateTime's as dates etcetera.

    0 讨论(0)
提交回复
热议问题