Skip to content

Commit d60fde2

Browse files
committed
Merge pull request #1491 from elastic/fix/guid-mapfromattributes
fix #1381 mapfromattributes now maps Guid to strings automatically
2 parents 8128cad + 844a1bd commit d60fde2

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

Diff for: src/Nest/Resolvers/Writers/TypeMappingWriter.cs

+2
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,8 @@ private string GetElasticsearchType(FieldType? fieldType)
300300
return FieldType.Date;
301301
case "Boolean":
302302
return FieldType.Boolean;
303+
case "Guid":
304+
return FieldType.String;
303305
}
304306
}
305307
else

Diff for: src/Tests/Nest.Tests.Integration/Mapping/MapFromAttributeTests.cs

+3
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ public class MapFromAttributeTests : IntegrationTests
1414
{
1515
class MapFromAttributeObject
1616
{
17+
public Guid Id { get; set; }
1718
public string Name { get; set; }
1819
[ElasticProperty(Type = FieldType.Nested, IncludeInParent = true)]
1920
public List<NestedObject> NestedObjects { get; set; }
@@ -36,6 +37,8 @@ public void InlcudeInParent()
3637
var typeMapping = this.Client.GetMapping<MapFromAttributeObject>(i => i.Type("mapfromattributeobject"));
3738
typeMapping.Should().NotBeNull();
3839

40+
typeMapping.Mapping.Properties["id"].Type.Name.Should().Be("string");
41+
3942
typeMapping.Mapping.Properties["nestedObjects"].Type.Name.Should().Be("nested");
4043
typeMapping.Mapping.Properties["nestedObjectsDontIncludeInParent"].Type.Name.Should().Be("nested");
4144
var nestedObject = typeMapping.Mapping.Properties["nestedObjects"] as NestedObjectMapping;

0 commit comments

Comments
 (0)