Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 0 additions & 18 deletions src/Nest/CommonAbstractions/ConnectionSettings/ClrTypeDefaults.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,6 @@ public interface IClrTypeMapping
/// </summary>
string RelationName { get; set; }

/// <summary>
/// The default Elasticsearch type name for the given <see cref="ClrType" />
/// </summary>
string TypeName { get; set; }

/// <summary>Disables Id inference for the given <see cref="ClrType"/>.
/// By default, the _id value for a document is inferred from a property named Id,
/// or from the property named by <see cref="IdPropertyName"/>, if set.
Expand Down Expand Up @@ -71,9 +66,6 @@ public class ClrTypeMapping : IClrTypeMapping
/// <inheritdoc />
public string RelationName { get; set; }

/// <inheritdoc />
public string TypeName { get; set; }

/// <inheritdoc />
public bool DisableIdInference { get; set; }
}
Expand Down Expand Up @@ -106,15 +98,11 @@ public class ClrTypeMappingDescriptor : DescriptorBase<ClrTypeMappingDescriptor,
string IClrTypeMapping.IdPropertyName { get; set; }
string IClrTypeMapping.IndexName { get; set; }
string IClrTypeMapping.RelationName { get; set; }
string IClrTypeMapping.TypeName { get; set; }
bool IClrTypeMapping.DisableIdInference { get; set; }

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

/// <inheritdoc cref="IClrTypeMapping.TypeName"/>
public ClrTypeMappingDescriptor TypeName(string typeName) => Assign(typeName, (a, v) => a.TypeName = v);

/// <inheritdoc cref="IClrTypeMapping.RelationName"/>
public ClrTypeMappingDescriptor RelationName(string relationName) => Assign(relationName, (a, v) => a.RelationName = v);

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

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

/// <summary>
/// The default Elasticsearch type name for <typeparamref name="TDocument" />
/// </summary>
public ClrTypeMappingDescriptor<TDocument> TypeName(string typeName) => Assign(typeName, (a, v) => a.TypeName = v);

/// <summary>
/// The relation name for <typeparamref name="TDocument" /> to resolve to.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,6 @@ public abstract class ConnectionSettingsBase<TConnectionSettings> : ConnectionCo

private readonly FluentDictionary<Type, string> _defaultRelationNames;

private readonly FluentDictionary<Type, string> _defaultTypeNames;

private readonly FluentDictionary<Type, string> _idProperties = new FluentDictionary<Type, string>();

private readonly Inferrer _inferrer;
Expand Down Expand Up @@ -94,7 +92,6 @@ IPropertyMappingProvider propertyMappingProvider

_defaultFieldNameInferrer = p => p.ToCamelCase();
_defaultIndices = new FluentDictionary<Type, string>();
_defaultTypeNames = new FluentDictionary<Type, string>();
_defaultRelationNames = new FluentDictionary<Type, string>();
_inferrer = new Inferrer(this);
}
Expand Down Expand Up @@ -216,9 +213,6 @@ public TConnectionSettings DefaultMappingFor<TDocument>(Func<ClrTypeMappingDescr
if (!inferMapping.IndexName.IsNullOrEmpty())
_defaultIndices.Add(inferMapping.ClrType, inferMapping.IndexName);

if (!inferMapping.TypeName.IsNullOrEmpty())
_defaultTypeNames.Add(inferMapping.ClrType, inferMapping.TypeName);

if (!inferMapping.RelationName.IsNullOrEmpty())
_defaultRelationNames.Add(inferMapping.ClrType, inferMapping.RelationName);

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

if (!inferMapping.TypeName.IsNullOrEmpty())
_defaultTypeNames.Add(inferMapping.ClrType, inferMapping.TypeName);

if (!inferMapping.RelationName.IsNullOrEmpty())
_defaultRelationNames.Add(inferMapping.ClrType, inferMapping.RelationName);

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

if (!inferMapping.TypeName.IsNullOrEmpty())
_defaultTypeNames.Add(inferMapping.ClrType, inferMapping.TypeName);

if (!inferMapping.RelationName.IsNullOrEmpty())
_defaultRelationNames.Add(inferMapping.ClrType, inferMapping.RelationName);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,10 @@ public static ConnectionSettings ApplyDomainSettings(this ConnectionSettings set
.IndexName(TestValueHelper.ProjectsIndex)
.IdProperty(p => p.Name)
.RelationName("project")
.TypeName("doc")
)
.DefaultMappingFor<CommitActivity>(map => map
.IndexName(TestValueHelper.ProjectsIndex)
.RelationName("commits")
.TypeName("doc")
)
.DefaultMappingFor<Developer>(map => map
.IndexName("devs")
Expand All @@ -25,14 +23,12 @@ public static ConnectionSettings ApplyDomainSettings(this ConnectionSettings set
)
.DefaultMappingFor<ProjectPercolation>(map => map
.IndexName("queries")
.TypeName(TestValueHelper.PercolatorType)
)
.DefaultMappingFor<Metric>(map => map
.IndexName("server-metrics")
)
.DefaultMappingFor<Shape>(map => map
.IndexName("shapes")
.TypeName("doc")
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ public void AvailableOptions()
var connectionSettings = new ConnectionSettings()
.DefaultMappingFor<Project>(i => i
.IndexName("my-projects")
.TypeName("project")
)
.EnableDebugMode()
.PrettyJson()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,10 @@ [U] public void RelationNameConfiguration()
var settings = new ConnectionSettings()
.DefaultMappingFor<CommitActivity>(m => m
.IndexName("projects-and-commits")
.TypeName("doc")
.RelationName("commits")
)
.DefaultMappingFor<Project>(m => m
.IndexName("projects-and-commits")
.TypeName("doc")
.RelationName("projects")
);

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

var resolver = new RelationNameResolver(settings);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,6 @@ public void OverridingInheritedProperties()
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.
.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.
.DefaultMappingFor<ParentWithStringId>(m => m
.TypeName("parent")
.Ignore(p => p.Description)
.Ignore(p => p.IgnoreMe)
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,9 @@ public void SimpleParentChildMapping()
{
var connectionPool = new SingleNodeConnectionPool(new Uri("http://localhost:9200"));
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.
.DefaultMappingFor<MyDocument>(m => m.IndexName("index").TypeName("doc"))
.DefaultMappingFor<MyChild>(m => m.IndexName("index").TypeName("doc"))
.DefaultMappingFor<MyParent>(m => m.IndexName("index").TypeName("doc").RelationName("parent"));
.DefaultMappingFor<MyDocument>(m => m.IndexName("index"))
.DefaultMappingFor<MyChild>(m => m.IndexName("index"))
.DefaultMappingFor<MyParent>(m => m.IndexName("index").RelationName("parent"));

var client = new ElasticClient(connectionSettings);

Expand Down