Skip to content

Commit 8462393

Browse files
authored
Remove default TypeNames and TypeName from IClrTypeMapping (#3808)
This commit removes the defaultTypeNames mappings on ConnectionSettings as they are no longer used. The TypeName on IClrTypeMapping is also removed as it too is no longer used.
1 parent 1e8bb3c commit 8462393

File tree

7 files changed

+3
-42
lines changed

7 files changed

+3
-42
lines changed

src/Nest/CommonAbstractions/ConnectionSettings/ClrTypeDefaults.cs

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,6 @@ public interface IClrTypeMapping
2626
/// </summary>
2727
string RelationName { get; set; }
2828

29-
/// <summary>
30-
/// The default Elasticsearch type name for the given <see cref="ClrType" />
31-
/// </summary>
32-
string TypeName { get; set; }
33-
3429
/// <summary>Disables Id inference for the given <see cref="ClrType"/>.
3530
/// By default, the _id value for a document is inferred from a property named Id,
3631
/// or from the property named by <see cref="IdPropertyName"/>, if set.
@@ -71,9 +66,6 @@ public class ClrTypeMapping : IClrTypeMapping
7166
/// <inheritdoc />
7267
public string RelationName { get; set; }
7368

74-
/// <inheritdoc />
75-
public string TypeName { get; set; }
76-
7769
/// <inheritdoc />
7870
public bool DisableIdInference { get; set; }
7971
}
@@ -106,15 +98,11 @@ public class ClrTypeMappingDescriptor : DescriptorBase<ClrTypeMappingDescriptor,
10698
string IClrTypeMapping.IdPropertyName { get; set; }
10799
string IClrTypeMapping.IndexName { get; set; }
108100
string IClrTypeMapping.RelationName { get; set; }
109-
string IClrTypeMapping.TypeName { get; set; }
110101
bool IClrTypeMapping.DisableIdInference { get; set; }
111102

112103
/// <inheritdoc cref="IClrTypeMapping.IndexName"/>
113104
public ClrTypeMappingDescriptor IndexName(string indexName) => Assign(indexName, (a, v) => a.IndexName = v);
114105

115-
/// <inheritdoc cref="IClrTypeMapping.TypeName"/>
116-
public ClrTypeMappingDescriptor TypeName(string typeName) => Assign(typeName, (a, v) => a.TypeName = v);
117-
118106
/// <inheritdoc cref="IClrTypeMapping.RelationName"/>
119107
public ClrTypeMappingDescriptor RelationName(string relationName) => Assign(relationName, (a, v) => a.RelationName = v);
120108

@@ -136,19 +124,13 @@ public class ClrTypeMappingDescriptor<TDocument>
136124
IList<IClrPropertyMapping<TDocument>> IClrTypeMapping<TDocument>.Properties { get; set; } = new List<IClrPropertyMapping<TDocument>>();
137125
string IClrTypeMapping.RelationName { get; set; }
138126
Expression<Func<TDocument, object>> IClrTypeMapping<TDocument>.RoutingProperty { get; set; }
139-
string IClrTypeMapping.TypeName { get; set; }
140127
bool IClrTypeMapping.DisableIdInference { get; set; }
141128

142129
/// <summary>
143130
/// The default Elasticsearch index name for <typeparamref name="TDocument" />
144131
/// </summary>
145132
public ClrTypeMappingDescriptor<TDocument> IndexName(string indexName) => Assign(indexName, (a, v) => a.IndexName = v);
146133

147-
/// <summary>
148-
/// The default Elasticsearch type name for <typeparamref name="TDocument" />
149-
/// </summary>
150-
public ClrTypeMappingDescriptor<TDocument> TypeName(string typeName) => Assign(typeName, (a, v) => a.TypeName = v);
151-
152134
/// <summary>
153135
/// The relation name for <typeparamref name="TDocument" /> to resolve to.
154136
/// </summary>

src/Nest/CommonAbstractions/ConnectionSettings/ConnectionSettingsBase.cs

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,6 @@ public abstract class ConnectionSettingsBase<TConnectionSettings> : ConnectionCo
5656

5757
private readonly FluentDictionary<Type, string> _defaultRelationNames;
5858

59-
private readonly FluentDictionary<Type, string> _defaultTypeNames;
60-
6159
private readonly FluentDictionary<Type, string> _idProperties = new FluentDictionary<Type, string>();
6260

6361
private readonly Inferrer _inferrer;
@@ -94,7 +92,6 @@ IPropertyMappingProvider propertyMappingProvider
9492

9593
_defaultFieldNameInferrer = p => p.ToCamelCase();
9694
_defaultIndices = new FluentDictionary<Type, string>();
97-
_defaultTypeNames = new FluentDictionary<Type, string>();
9895
_defaultRelationNames = new FluentDictionary<Type, string>();
9996
_inferrer = new Inferrer(this);
10097
}
@@ -216,9 +213,6 @@ public TConnectionSettings DefaultMappingFor<TDocument>(Func<ClrTypeMappingDescr
216213
if (!inferMapping.IndexName.IsNullOrEmpty())
217214
_defaultIndices.Add(inferMapping.ClrType, inferMapping.IndexName);
218215

219-
if (!inferMapping.TypeName.IsNullOrEmpty())
220-
_defaultTypeNames.Add(inferMapping.ClrType, inferMapping.TypeName);
221-
222216
if (!inferMapping.RelationName.IsNullOrEmpty())
223217
_defaultRelationNames.Add(inferMapping.ClrType, inferMapping.RelationName);
224218

@@ -250,9 +244,6 @@ public TConnectionSettings DefaultMappingFor(Type documentType, Func<ClrTypeMapp
250244
if (!inferMapping.IndexName.IsNullOrEmpty())
251245
_defaultIndices.Add(inferMapping.ClrType, inferMapping.IndexName);
252246

253-
if (!inferMapping.TypeName.IsNullOrEmpty())
254-
_defaultTypeNames.Add(inferMapping.ClrType, inferMapping.TypeName);
255-
256247
if (!inferMapping.RelationName.IsNullOrEmpty())
257248
_defaultRelationNames.Add(inferMapping.ClrType, inferMapping.RelationName);
258249

@@ -272,9 +263,6 @@ public TConnectionSettings DefaultMappingFor(IEnumerable<IClrTypeMapping> typeMa
272263
if (!inferMapping.IndexName.IsNullOrEmpty())
273264
_defaultIndices.Add(inferMapping.ClrType, inferMapping.IndexName);
274265

275-
if (!inferMapping.TypeName.IsNullOrEmpty())
276-
_defaultTypeNames.Add(inferMapping.ClrType, inferMapping.TypeName);
277-
278266
if (!inferMapping.RelationName.IsNullOrEmpty())
279267
_defaultRelationNames.Add(inferMapping.ClrType, inferMapping.RelationName);
280268
}

src/Tests/Tests.Domain/Extensions/ConnectionSettingsExtensions.cs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,10 @@ public static ConnectionSettings ApplyDomainSettings(this ConnectionSettings set
1111
.IndexName(TestValueHelper.ProjectsIndex)
1212
.IdProperty(p => p.Name)
1313
.RelationName("project")
14-
.TypeName("doc")
1514
)
1615
.DefaultMappingFor<CommitActivity>(map => map
1716
.IndexName(TestValueHelper.ProjectsIndex)
1817
.RelationName("commits")
19-
.TypeName("doc")
2018
)
2119
.DefaultMappingFor<Developer>(map => map
2220
.IndexName("devs")
@@ -25,14 +23,12 @@ public static ConnectionSettings ApplyDomainSettings(this ConnectionSettings set
2523
)
2624
.DefaultMappingFor<ProjectPercolation>(map => map
2725
.IndexName("queries")
28-
.TypeName(TestValueHelper.PercolatorType)
2926
)
3027
.DefaultMappingFor<Metric>(map => map
3128
.IndexName("server-metrics")
3229
)
3330
.DefaultMappingFor<Shape>(map => map
3431
.IndexName("shapes")
35-
.TypeName("doc")
3632
);
3733
}
3834
}

src/Tests/Tests/ClientConcepts/Connection/ConfigurationOptions.doc.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ public void AvailableOptions()
4949
var connectionSettings = new ConnectionSettings()
5050
.DefaultMappingFor<Project>(i => i
5151
.IndexName("my-projects")
52-
.TypeName("project")
5352
)
5453
.EnableDebugMode()
5554
.PrettyJson()

src/Tests/Tests/ClientConcepts/HighLevel/Inference/TypesAndRelationsInference.doc.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,10 @@ [U] public void RelationNameConfiguration()
3939
var settings = new ConnectionSettings()
4040
.DefaultMappingFor<CommitActivity>(m => m
4141
.IndexName("projects-and-commits")
42-
.TypeName("doc")
4342
.RelationName("commits")
4443
)
4544
.DefaultMappingFor<Project>(m => m
4645
.IndexName("projects-and-commits")
47-
.TypeName("doc")
4846
.RelationName("projects")
4947
);
5048

@@ -67,7 +65,6 @@ [U] public void TypeNameExplicitConfigurationDoesNotAffectRelationName()
6765
var settings = new ConnectionSettings()
6866
.DefaultMappingFor<Project>(m => m
6967
.IndexName("projects-and-commits")
70-
.TypeName("doc")
7168
);
7269

7370
var resolver = new RelationNameResolver(settings);

src/Tests/Tests/ClientConcepts/HighLevel/Mapping/AutoMap.doc.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,6 @@ public void OverridingInheritedProperties()
161161
var connectionSettings = new ConnectionSettings(new InMemoryConnection()) // <1> we're using an _in memory_ connection for this example. In your production application though, you'll want to use an `IConnection` that actually sends a request.
162162
.DisableDirectStreaming() // <2> we disable direct streaming here to capture the request and response bytes. In your production application however, you'll likely not want to do this, since it causes the request and response bytes to be buffered in memory.
163163
.DefaultMappingFor<ParentWithStringId>(m => m
164-
.TypeName("parent")
165164
.Ignore(p => p.Description)
166165
.Ignore(p => p.IgnoreMe)
167166
);

src/Tests/Tests/ClientConcepts/HighLevel/Mapping/ParentChildRelationships.doc.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,9 @@ public void SimpleParentChildMapping()
7777
{
7878
var connectionPool = new SingleNodeConnectionPool(new Uri("http://localhost:9200"));
7979
var connectionSettings = new ConnectionSettings(connectionPool, new InMemoryConnection()) // <1> for the purposes of this example, an in memory connection is used which doesn't actually send a request. In your application, you'd use the default connection or your own implementation that actually sends a request.
80-
.DefaultMappingFor<MyDocument>(m => m.IndexName("index").TypeName("doc"))
81-
.DefaultMappingFor<MyChild>(m => m.IndexName("index").TypeName("doc"))
82-
.DefaultMappingFor<MyParent>(m => m.IndexName("index").TypeName("doc").RelationName("parent"));
80+
.DefaultMappingFor<MyDocument>(m => m.IndexName("index"))
81+
.DefaultMappingFor<MyChild>(m => m.IndexName("index"))
82+
.DefaultMappingFor<MyParent>(m => m.IndexName("index").RelationName("parent"));
8383

8484
var client = new ElasticClient(connectionSettings);
8585

0 commit comments

Comments
 (0)