Reputation: 106
Currently, I have been adding mapping through REST Api and programatically indexing documents using NEST.
However, I recently came across NEST's DefaultMappingFor (in ConnectionSettings) and wondering how it's used. (Won't be able to spike soon hence asking.)
Question: In the source code, if I set mapping using the DefaultMappingFor, does that mean it is not necessary to create the mapping using the Rest Api because, maybe(I think), and NEST will use the declared default mapping whenever a document is indexed?
Thank you.
Upvotes: 2
Views: 3867
Reputation: 125528
DefaultMappingFor()
and DefaultMappingFor<T>()
allows you to configure defaults for a given CLR type. Both allow you to configure:
.IndexName()
method.TypeName()
method.RelationName()
methodIn addition, DefaultMappingFor<T>()
allows you to configure:
.IdProperty()
method.Routing()
method.Ignore()
method.PropertyName()
methodSetting any of these for a type means that NEST will use these over any conventions it has. The typical ones to use are .IndexName()
and .TypeName()
(although types are removed in Elasticsearch 6.x), and means that you don't need to specify either of these on each request (unless you want to override this default mapping too).
Upvotes: 3