Chrono
Chrono

Reputation: 1473

Mapping nested types using NEST 1.0

I'm trying to create a mapping with a nested type using NEST 1.0. The previous answer for this question doesn't work anymore in the latest version of NEST because NestedObject doesn't seem to be part of the API anymore. (This is also noted in a comment on the accepted answer)

Having looked at the list of breaking changes with version 1.0 I can't find anything about changes to mapping nested types. And the documentation also doesn't seem to provide an example of such a mapping.

So how do I create a nested mapping with NEST 1.0?

Upvotes: 1

Views: 735

Answers (1)

Manolis
Manolis

Reputation: 738

Try using this fluent syntax in order to perform the mapping of a Nested object. This works and it's tested for NEST up to 1.3.1 (current version 1.4.3).

client.CreateIndex(c => c
     .Index(indexName)
     .InitializeUsing(indexSettings)
     .AddMapping<OutterObjectType>(m => m
         .Properties(p => p
             .NestedObject<NestedObjectType>(n => n
                  .Name("NestedObjectName")))));   

Upvotes: 4

Related Questions