Skip to content

Commit 078d521

Browse files
committed
Merge branch 'fix/mappings'
2 parents f5ad42f + 4353b68 commit 078d521

File tree

15 files changed

+574
-31
lines changed

15 files changed

+574
-31
lines changed

build/scripts/Building.fsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ type Build() =
5858
| "Nest"
5959
| "Elasticsearch.Net" ->
6060
gitLink (Paths.Net45BinFolder projectName) projectName
61+
gitLink (Paths.Net46BinFolder projectName) projectName
6162
gitLink (Paths.DotNet51BinFolder projectName) projectName
6263
| _ -> ()
6364
CopyDir outputFolder binFolder allFiles

build/scripts/Paths.fsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,10 @@ module Paths =
4848
let binFolder = BinFolder projectName
4949
sprintf "%s/net45" binFolder
5050

51+
let Net46BinFolder(projectName) =
52+
let binFolder = BinFolder projectName
53+
sprintf "%s/net46" binFolder
54+
5155
let DotNet51BinFolder(projectName) =
5256
let binFolder = BinFolder(projectName)
5357
sprintf "%s/dotnet5.1" binFolder

src/Nest/Mapping/Types/Specialized/Attachment/AttachmentProperty.cs

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
using System;
2-
using System.Collections;
2+
using System.Collections.Generic;
33
using Newtonsoft.Json;
44

55
namespace Nest
@@ -22,7 +22,7 @@ public class AttachmentProperty : PropertyBase, IAttachmentProperty
2222
{
2323
public AttachmentProperty() : base("attachment") { }
2424

25-
private IDictionary Dictionary => this.Fields;
25+
private IDictionary<PropertyName, IProperty> Dictionary => this.Fields ?? (this.Fields = new Properties());
2626

2727
public IStringProperty AuthorField
2828
{
@@ -50,8 +50,8 @@ public IDateProperty DateField
5050

5151
public IStringProperty FileField
5252
{
53-
get { return Dictionary["file"] as IStringProperty; }
54-
set { Dictionary["file"] = value; }
53+
get { return Dictionary["content"] as IStringProperty; }
54+
set { Dictionary["content"] = value; }
5555
}
5656

5757
public IStringProperty KeywordsField
@@ -93,7 +93,7 @@ public class AttachmentPropertyDescriptor<T>
9393
INumberProperty IAttachmentProperty.ContentLengthField { get; set; }
9494
IStringProperty IAttachmentProperty.LanguageField { get; set; }
9595

96-
private IDictionary Dictionary => Self.Fields;
96+
private IDictionary<PropertyName, IProperty> Dictionary => Self.Fields ?? (Self.Fields = new Properties());
9797

9898
public AttachmentPropertyDescriptor() : base("attachment") { }
9999

@@ -117,7 +117,7 @@ public AttachmentPropertyDescriptor<T> NameField(Func<StringPropertyDescriptor<T
117117
SetMetadataField(selector, "name");
118118

119119
public AttachmentPropertyDescriptor<T> FileField(Func<StringPropertyDescriptor<T>, IStringProperty> selector) =>
120-
SetMetadataField(selector, "file");
120+
SetMetadataField(selector, "content");
121121

122122
public AttachmentPropertyDescriptor<T> AuthorField(Func<StringPropertyDescriptor<T>, IStringProperty> selector) =>
123123
SetMetadataField(selector, "author");
@@ -128,10 +128,18 @@ public AttachmentPropertyDescriptor<T> KeywordsField(Func<StringPropertyDescript
128128
public AttachmentPropertyDescriptor<T> ContentTypeField(Func<StringPropertyDescriptor<T>, IStringProperty> selector) =>
129129
SetMetadataField(selector, "content_type");
130130

131+
[Obsolete("Use ContentLengthField(Func<NumberPropertyDescriptor<T>, INumberProperty> selector)")]
131132
public AttachmentPropertyDescriptor<T> ContentLengthField(Func<StringPropertyDescriptor<T>, IStringProperty> selector) =>
132133
SetMetadataField(selector, "content_length");
133134

135+
public AttachmentPropertyDescriptor<T> ContentLengthField(Func<NumberPropertyDescriptor<T>, INumberProperty> selector) =>
136+
SetMetadataField(selector, "content_length");
137+
138+
[Obsolete("Use LanguageField(Func<StringPropertyDescriptor<T>, IStringProperty> selector)")]
134139
public AttachmentPropertyDescriptor<T> LanguageField(Func<NumberPropertyDescriptor<T>, INumberProperty> selector) =>
135140
SetMetadataField(selector, "language");
141+
142+
public AttachmentPropertyDescriptor<T> LanguageField(Func<StringPropertyDescriptor<T>, IStringProperty> selector) =>
143+
SetMetadataField(selector, "language");
136144
}
137145
}

src/Nest/Mapping/Visitor/IMappingVisitor.cs

Lines changed: 77 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
1-
namespace Nest
1+
using System;
2+
3+
namespace Nest
24
{
35
public interface IMappingVisitor
46
{
57
int Depth { get; set; }
68
void Visit(TypeMapping mapping);
79
void Visit(StringProperty mapping);
10+
[Obsolete("Use Visit(NumberProperty mapping) for number mappings")]
811
void Visit(NumberType mapping);
912
void Visit(DateProperty mapping);
1013
void Visit(BooleanProperty mapping);
@@ -16,5 +19,78 @@ public interface IMappingVisitor
1619
void Visit(GeoShapeProperty mapping);
1720
void Visit(AttachmentProperty mapping);
1821
void Visit(NumberProperty mapping);
22+
void Visit(CompletionProperty mapping);
23+
void Visit(Murmur3HashProperty mapping);
24+
void Visit(TokenCountProperty mapping);
25+
}
26+
27+
public class NoopMappingVisitor : IMappingVisitor
28+
{
29+
public virtual int Depth { get; set; }
30+
31+
public virtual void Visit(TypeMapping mapping)
32+
{
33+
}
34+
35+
public virtual void Visit(StringProperty mapping)
36+
{
37+
}
38+
39+
[Obsolete("Use Visit(NumberProperty mapping) for number mappings")]
40+
public virtual void Visit(NumberType mapping)
41+
{
42+
}
43+
44+
public virtual void Visit(DateProperty mapping)
45+
{
46+
}
47+
48+
public virtual void Visit(BooleanProperty mapping)
49+
{
50+
}
51+
52+
public virtual void Visit(BinaryProperty mapping)
53+
{
54+
}
55+
56+
public virtual void Visit(ObjectProperty mapping)
57+
{
58+
}
59+
60+
public virtual void Visit(NestedProperty mapping)
61+
{
62+
}
63+
64+
public virtual void Visit(IpProperty mapping)
65+
{
66+
}
67+
68+
public virtual void Visit(GeoPointProperty mapping)
69+
{
70+
}
71+
72+
public virtual void Visit(GeoShapeProperty mapping)
73+
{
74+
}
75+
76+
public virtual void Visit(AttachmentProperty mapping)
77+
{
78+
}
79+
80+
public virtual void Visit(NumberProperty mapping)
81+
{
82+
}
83+
84+
public virtual void Visit(CompletionProperty mapping)
85+
{
86+
}
87+
88+
public virtual void Visit(Murmur3HashProperty mapping)
89+
{
90+
}
91+
92+
public virtual void Visit(TokenCountProperty mapping)
93+
{
94+
}
1995
}
2096
}

src/Nest/Mapping/Visitor/MappingWalker.cs

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,24 +90,45 @@ public void Accept(IProperties properties)
9090
var i = field as IpProperty;
9191
if (i == null) continue;
9292
this._visitor.Visit(i);
93+
this.Accept(i.Fields);
9394
break;
9495
case "geo_point":
9596
var gp = field as GeoPointProperty;
9697
if (gp == null) continue;
9798
this._visitor.Visit(gp);
99+
this.Accept(gp.Fields);
98100
break;
99101
case "geo_shape":
100102
var gs = field as GeoShapeProperty;
101103
if (gs == null) continue;
102104
this._visitor.Visit(gs);
105+
this.Accept(gs.Fields);
103106
break;
104107
case "attachment":
105108
var a = field as AttachmentProperty;
106109
if (a == null) continue;
107110
this._visitor.Visit(a);
111+
this.Accept(a.Fields);
112+
break;
113+
case "completion":
114+
var c = field as CompletionProperty;
115+
if (c == null) continue;
116+
this._visitor.Visit(c);
117+
this.Accept(c.Fields);
118+
break;
119+
case "murmur3":
120+
var mm = field as Murmur3HashProperty;
121+
if (mm == null) continue;
122+
this._visitor.Visit(mm);
123+
this.Accept(mm.Fields);
124+
break;
125+
case "token_count":
126+
var tc = field as TokenCountProperty;
127+
if (tc == null) continue;
128+
this._visitor.Visit(tc);
129+
this.Accept(tc.Fields);
108130
break;
109131
}
110-
111132
}
112133
}
113134
}

src/Tests/Aggregations/Bucket/DateHistogram/DateHistogramAggregationUsageTests.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ namespace Tests.Aggregations.Bucket.DateHistogram
1313
* From a functionality perspective, this histogram supports the same features as the normal histogram.
1414
* The main difference is that the interval can be specified by date/time expressions.
1515
*
16-
* When specifying a format and extended_bounds, in order for Elasticsearch to be able to parse
17-
* the serialized DateTimes of extended_bounds correctly, the date_optional_time format is included
18-
* as part of the format value.
16+
* When both format and extended_bounds are specified, the `date_optional_time` format is included
17+
* as part of the format value so that Elasticsearch to be able to parse
18+
* the serialized DateTimes of extended_bounds correctly.
1919
*
2020
* Be sure to read the elasticsearch documentation {ref}/search-aggregations-bucket-datehistogram-aggregation.html[on this subject here]
2121
*/

src/Tests/Aggregations/Bucket/Filters/FiltersAggregationUsageTests.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,14 @@
99

1010
namespace Tests.Aggregations.Bucket.Filters
1111
{
12-
/**
12+
/** == Named filters
13+
*
1314
* Defines a multi bucket aggregations where each bucket is associated with a filter.
1415
* Each bucket will collect all documents that match its associated filter. For documents
1516
* that do not match any filter, these will be collected in the other bucket.
1617
*
1718
* Be sure to read the elasticsearch documentation {ref}/search-aggregations-bucket-filters-aggregation.html[on this subject here]
1819
*/
19-
20-
/** == Named filters **/
2120
public class FiltersAggregationUsageTests : AggregationUsageTestBase
2221
{
2322
public FiltersAggregationUsageTests(ReadOnlyCluster i, EndpointUsage usage) : base(i, usage) { }
@@ -111,7 +110,6 @@ protected override void ExpectResponse(ISearchResponse<Project> response)
111110
}
112111

113112
/** == Anonymous filters **/
114-
115113
public class AnonymousUsage : AggregationUsageTestBase
116114
{
117115
public AnonymousUsage(ReadOnlyCluster i, EndpointUsage usage) : base(i, usage) { }

src/Tests/ClientConcepts/LowLevel/PostData.doc.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ namespace Tests.ClientConcepts.LowLevel
1313
{
1414
public class PostingData
1515
{
16-
/** # Post data
16+
/** ## Post data
1717
* The low level allows you to post a string, byte[] array directly. On top of this if you pass a list of strings or objects
1818
* they will be serialized in Elasticsearch's special bulk/multi format.
1919
*/

src/Tests/Document/Single/Attachment/AttachmentApiTests.cs

Lines changed: 135 additions & 0 deletions
Large diffs are not rendered by default.
Binary file not shown.

0 commit comments

Comments
 (0)