Skip to content

Conversation

@nordbergm
Copy link
Contributor

This change allows you to use the PutMappingDescriptor's existing Type method to override the type name of a mapping at index creation.

Since it was already supported for PutMapping, having it at index creation too made sense.

The use case is pretty simple. If you have a base class which you want to either use attribute mappings for, or fluent mapping, you could put that base class mapping as "default" by doing something like:

_client.CreateIndex("index",
                    c =>
                    c.AddMapping<Entity>(
                        map =>
                            map.Type("_default_")
                               .Properties(p => p.String(s => s.Name(n => n.Name)
                                                           .Index(FieldIndexOption.analyzed)
                                                           .Store(false)
                                                           .IncludeInAll()))
                               .DynamicTemplates(d => d.Add(a =>
                                                            a.Name("other")
                                                             .Match("*")
                                                             .Mapping(m => m.Generic(g => g.Index("not_analyzed")
                                                                                           .IncludeInAll(false)))))))

@Mpdreamz
Copy link
Member

Thanks @nordbergm seems rather silly this wasn't already supported :)

Mpdreamz added a commit that referenced this pull request Apr 27, 2014
…dden

allow type name to be overridden when adding mappings at index creation
@Mpdreamz Mpdreamz merged commit 2b1c694 into elastic:master Apr 27, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants