The official Nest developers answered this question in their github, linked here.
Basically, you don't use Func<PutMappingDescriptor<Project>, IPutMappingRequest>
but PutMappingDescriptor<Project>
directly. by newing up a PutMappingDescriptor<Project>
and build up your fluent mapping from there.
Creating index expects ITypeMapping
while updating index expects IPutMappingRequest
which implements ITypeMapping
. So you can satisfy both by using PutMappingDescriptor
.
To create an index, use:
```
client.CreateIndex("projects", c => c
.Mappings(ms => ms
.Map(m => GetMapping())
)
);
```
where you ignore m
passed in in the lambda and use the one you created. The reason why you can do that can be found in NEST's source code where it creates an empty TypeMappingDescriptor for your to further build upon:
public MappingsDescriptor Map<T>(Func<TypeMappingDescriptor<T>, ITypeMapping> selector) where T : class =>
Assign(typeof (T), selector?.Invoke(new TypeMappingDescriptor<T>()));
To update mapping, do:
client.Map(GetMapping());