Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allow type name to be overridden when adding mappings at index creation #595

Merged

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