Skip to content

Commit b07fe8d

Browse files
committed
moved all Resolvement of typenames/indexnames/id's into ElasticInferrer which is exposed as .Infer on IElasticClient
1 parent 6831d2d commit b07fe8d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+411
-397
lines changed

src/Nest.Tests.Integration/Core/Bulk/BulkPercolateTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,12 @@ public void BulkIndexWithPercolate()
4848

4949
indexResponses.First().Id.Should().BeEquivalentTo("2");
5050
indexResponses.First().Index.Should().BeEquivalentTo(ElasticsearchConfiguration.DefaultIndex);
51-
indexResponses.First().Type.Should().BeEquivalentTo(this.GetTypeNameFor<ElasticSearchProject>());
51+
indexResponses.First().Type.Should().BeEquivalentTo(this._client.Infer.TypeName<ElasticSearchProject>());
5252
indexResponses.First().Matches.Should().NotBeNull();
5353

5454
indexResponses.ElementAt(1).Id.Should().BeEquivalentTo("3");
5555
indexResponses.ElementAt(1).Index.Should().BeEquivalentTo(ElasticsearchConfiguration.DefaultIndex);
56-
indexResponses.ElementAt(1).Type.Should().BeEquivalentTo(this.GetTypeNameFor<ElasticSearchProject>());
56+
indexResponses.ElementAt(1).Type.Should().BeEquivalentTo(this._client.Infer.TypeName<ElasticSearchProject>());
5757
indexResponses.First().Matches.Should().BeNull();
5858

5959
// cleanup

src/Nest.Tests.Integration/Core/Bulk/BulkTests.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,17 +33,17 @@ public void Bulk()
3333
deleteResponses.Should().HaveCount(1);
3434
deleteResponses.First().Id.Should().BeEquivalentTo("4");
3535
deleteResponses.First().Index.Should().BeEquivalentTo(ElasticsearchConfiguration.DefaultIndex);
36-
deleteResponses.First().Type.Should().BeEquivalentTo(this.GetTypeNameFor<ElasticSearchProject>());
36+
deleteResponses.First().Type.Should().BeEquivalentTo(this._client.Infer.TypeName<ElasticSearchProject>());
3737

3838
createResponses.Should().HaveCount(1);
3939
createResponses.First().Id.Should().BeEquivalentTo("123123");
4040
createResponses.First().Index.Should().BeEquivalentTo(ElasticsearchConfiguration.DefaultIndex);
41-
createResponses.First().Type.Should().BeEquivalentTo(this.GetTypeNameFor<ElasticSearchProject>());
41+
createResponses.First().Type.Should().BeEquivalentTo(this._client.Infer.TypeName<ElasticSearchProject>());
4242

4343
indexResponses.Should().HaveCount(1);
4444
indexResponses.First().Id.Should().BeEquivalentTo("2");
4545
indexResponses.First().Index.Should().BeEquivalentTo(ElasticsearchConfiguration.DefaultIndex);
46-
indexResponses.First().Type.Should().BeEquivalentTo(this.GetTypeNameFor<ElasticSearchProject>());
46+
indexResponses.First().Type.Should().BeEquivalentTo(this._client.Infer.TypeName<ElasticSearchProject>());
4747
}
4848

4949
[Test]

src/Nest.Tests.Integration/IntegrationTests.cs

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,19 +21,9 @@ protected virtual void ResetIndexes()
2121

2222
}
2323

24-
protected string GetTypeNameFor<T>() where T : class
25-
{
26-
return this.GetTypeNameFor(typeof (T));
27-
}
28-
protected string GetTypeNameFor(Type t)
29-
{
30-
return new TypeNameResolver().GetTypeNameFor(t).Resolve(this._settings);
31-
}
32-
33-
3424
protected IQueryResponse<T> SearchRaw<T>(string query) where T : class
3525
{
36-
var index = this._client.GetIndexNameFor<T>();
26+
var index = this._client.Infer.IndexName<T>();
3727
var typeName = this._client.GetTypeNameFor<T>();
3828
var connectionStatus = this._client.Raw.SearchPost(index, typeName, query);
3929
return connectionStatus.Deserialize<QueryResponse<T>>();

src/Nest.Tests.Integration/Search/CountTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public void SimpleQueryWithIndicesCount()
5454
//does a match_all on the default specified index
5555
var index = ElasticsearchConfiguration.DefaultIndex;
5656
var indices = new[] { index, index + "_clone" };
57-
var types = new[] { this.GetTypeNameFor<ElasticSearchProject>() };
57+
var types = new[] { this._client.Infer.TypeName<ElasticSearchProject>() };
5858
var countResults = this._client.Count<ElasticSearchProject>(indices, types, q => q
5959
.Fuzzy(fq => fq
6060
.PrefixLength(4)

src/Nest.Tests.Integration/Warmers/WarmersTests.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ namespace Nest.Tests.Integration.Warmers
1010
[TestFixture]
1111
public class WarmersTests : IntegrationTests
1212
{
13-
TypeNameResolver typeNameResolver = new TypeNameResolver();
1413
[Test]
1514
public void SimplePutAndGet()
1615
{
@@ -37,7 +36,7 @@ public void SimplePutAndGet()
3736
warmerResponse.Indices[_settings.DefaultIndex].Should().ContainKey("warmer_simpleputandget");
3837
var warmerMapping = warmerResponse.Indices[_settings.DefaultIndex]["warmer_simpleputandget"];
3938
warmerMapping.Name.Should().Be("warmer_simpleputandget");
40-
var typeName = typeNameResolver.GetTypeNameFor<ElasticSearchProject>().Resolve(_settings);
39+
var typeName = _client.Infer.TypeName<ElasticSearchProject>();
4140
warmerMapping.Types.Select(s => s.Resolve(_settings)).Contains(typeName).Should().Be(true);
4241
warmerMapping.Source.Should().Contain("\"strange-value\"");
4342
}

src/Nest.Tests.Unit/Core/AttributeBasedMap/BaseAttributeMappingTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ protected string CreateMapFor<T>() where T : class
1212
}
1313
protected string CreateMapFor(Type t)
1414
{
15-
var type = new TypeNameResolver().GetTypeNameFor(t);
15+
var type = TypeNameMarker.Create(t);
1616
var writer = new TypeMappingWriter(t, type, TestElasticClient.Settings, 10);
1717

1818
return writer.MapFromAttributes();

src/Nest/DSL/BulkCreateDescriptor.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@ public BulkCreateDescriptor()
2020
this._typeNameResolver = new TypeNameResolver();
2121
}
2222

23-
internal override string GetIdForObject(IdResolver resolver)
23+
internal override string GetIdForObject(ElasticInferrer inferrer)
2424
{
2525
if (!this._Id.IsNullOrEmpty())
2626
return this._Id;
2727

28-
return resolver.GetIdFor<T>((T)_Object);
28+
return inferrer.Id((T)_Object);
2929

3030
}
3131

src/Nest/DSL/BulkDeleteDescriptor.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@ public BulkDeleteDescriptor()
2020
this._typeNameResolver = new TypeNameResolver();
2121
}
2222

23-
internal override string GetIdForObject(IdResolver resolver)
23+
internal override string GetIdForObject(ElasticInferrer inferrer)
2424
{
2525
if (!this._Id.IsNullOrEmpty())
2626
return this._Id;
2727

28-
return resolver.GetIdFor<T>((T)_Object);
28+
return inferrer.Id((T)_Object);
2929

3030
}
3131

src/Nest/DSL/BulkIndexDescriptor.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@ public BulkIndexDescriptor()
2020
this._typeNameResolver = new TypeNameResolver();
2121
}
2222

23-
internal override string GetIdForObject(IdResolver resolver)
23+
internal override string GetIdForObject(ElasticInferrer inferrer)
2424
{
2525
if (!this._Id.IsNullOrEmpty())
2626
return this._Id;
2727

28-
return resolver.GetIdFor<T>((T)_Object);
28+
return inferrer.Id((T)_Object);
2929

3030
}
3131

src/Nest/DSL/BulkUpdateDescriptor.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,12 @@ internal override object GetBody()
5757
};
5858
}
5959

60-
internal override string GetIdForObject(IdResolver resolver)
60+
internal override string GetIdForObject(ElasticInferrer inferrer)
6161
{
6262
if (!this._Id.IsNullOrEmpty())
6363
return this._Id;
6464

65-
return resolver.GetIdFor<T>((T)_Object);
65+
return inferrer.Id((T)_Object);
6666

6767
}
6868

0 commit comments

Comments
 (0)