Skip to content

Commit c680e81

Browse files
committed
added a test to disproof #1476, index: not_analyzed mapping on numbers works as expected
1 parent 8128cad commit c680e81

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

src/Tests/Nest.Tests.Integration/Mapping/MapFromAttributeTests.cs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ public class MapFromAttributeTests : IntegrationTests
1515
class MapFromAttributeObject
1616
{
1717
public string Name { get; set; }
18+
public int Number { get; set; }
1819
[ElasticProperty(Type = FieldType.Nested, IncludeInParent = true)]
1920
public List<NestedObject> NestedObjects { get; set; }
2021
[ElasticProperty(Type = FieldType.Nested)]
@@ -45,5 +46,32 @@ public void InlcudeInParent()
4546
nestedObject.IncludeInParent.Should().BeTrue();
4647
nestedObjectDontincludeInParent.IncludeInParent.Should().NotHaveValue();
4748
}
49+
50+
[Test]
51+
public void NumberNotAnalyzedShouldBeNotAnalyzed()
52+
{
53+
var index = ElasticsearchConfiguration.NewUniqueIndexName();
54+
var indicesResponse = this.Client.CreateIndex(c=>c
55+
.Index(index)
56+
.AddMapping<MapFromAttributeObject>(m=>m
57+
.MapFromAttributes()
58+
.Properties(prop=>prop
59+
.Number(n=>n.Name(p=>p.Number).Index(NonStringIndexOption.NotAnalyzed))
60+
)
61+
)
62+
63+
);
64+
65+
indicesResponse.IsValid.Should().BeTrue();
66+
67+
var typeMapping = this.Client.GetMapping<MapFromAttributeObject>(i => i.Index(index));
68+
typeMapping.Should().NotBeNull();
69+
70+
var numberMapping = typeMapping.Mapping.Properties["number"] as NumberMapping;
71+
numberMapping.Should().NotBeNull();
72+
//index == null because not analyzed is default
73+
numberMapping.Index.Should().NotBe(NonStringIndexOption.Analyzed).And.BeNull();
74+
}
75+
4876
}
4977
}

0 commit comments

Comments
 (0)