Skip to content

Commit cf38792

Browse files
committed
BinaryMapping also inherit from MultiFieldMapping
1 parent 1d996bf commit cf38792

File tree

2 files changed

+27
-10
lines changed

2 files changed

+27
-10
lines changed

Diff for: src/Nest/Domain/Mapping/Descriptors/BinaryMappingDescriptor.cs

+22-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
namespace Nest
66
{
7-
public class BinaryMappingDescriptor<T>
7+
public class BinaryMappingDescriptor<T> where T : class
88
{
99
internal BinaryMapping _Mapping = new BinaryMapping();
1010

@@ -60,5 +60,26 @@ public BinaryMappingDescriptor<T> CopyTo(params Expression<Func<T, object>>[] ob
6060
this._Mapping.CopyTo = objectPaths.Select(e => (PropertyPathMarker)e);
6161
return this;
6262
}
63+
64+
public BinaryMappingDescriptor<T> Path(MultiFieldMappingPath path)
65+
{
66+
this._Mapping.Path = path.Value;
67+
return this;
68+
}
69+
70+
public BinaryMappingDescriptor<T> Fields(Func<CorePropertiesDescriptor<T>, CorePropertiesDescriptor<T>> fieldSelector)
71+
{
72+
fieldSelector.ThrowIfNull("fieldSelector");
73+
var properties = fieldSelector(new CorePropertiesDescriptor<T>());
74+
foreach (var p in properties.Properties)
75+
{
76+
var value = p.Value as IElasticCoreType;
77+
if (value == null)
78+
continue;
79+
80+
_Mapping.Fields[p.Key] = value;
81+
}
82+
return this;
83+
}
6384
}
6485
}

Diff for: src/Nest/Domain/Mapping/Types/BinaryMapping.cs

+5-9
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,12 @@
55
namespace Nest
66
{
77
[JsonObject(MemberSerialization.OptIn)]
8-
public class BinaryMapping : IElasticType, IElasticCoreType
8+
public class BinaryMapping : MultiFieldMapping, IElasticType, IElasticCoreType
99
{
10-
11-
public PropertyNameMarker Name { get; set; }
12-
13-
[JsonProperty("type")]
14-
public virtual TypeNameMarker Type { get { return new TypeNameMarker { Name = "binary" }; } }
15-
16-
[JsonProperty("similarity")]
17-
public string Similarity { get; set; }
10+
public BinaryMapping()
11+
: base("binary")
12+
{
13+
}
1814

1915
/// <summary>
2016
/// The name of the field that will be stored in the index. Defaults to the property/field name.

0 commit comments

Comments
 (0)