Skip to content

Commit e344795

Browse files
committed
added boost to several queries blatently missing them
1 parent 9ae56fd commit e344795

23 files changed

+348
-53
lines changed

Diff for: src/Nest/DSL/Query/CustomScoreQueryDescriptor.cs

+6
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ public interface ICustomScoreQuery : IQuery
2323
[JsonProperty(PropertyName = "query")]
2424
[JsonConverter(typeof(CompositeJsonConverter<ReadAsTypeConverter<QueryDescriptor<object>>, CustomJsonConverter>))]
2525
IQueryContainer Query { get; set; }
26+
2627
}
2728

2829
public class CustomScoreQuery : PlainQuery, ICustomScoreQuery
@@ -33,10 +34,15 @@ protected override void WrapInContainer(IQueryContainer container)
3334
}
3435

3536
public string Name { get; set; }
37+
3638
bool IQuery.IsConditionless { get { return false; } }
39+
3740
public string Lang { get; set; }
41+
3842
public string Script { get; set; }
43+
3944
public Dictionary<string, object> Params { get; set; }
45+
4046
public IQueryContainer Query { get; set; }
4147
}
4248

Diff for: src/Nest/DSL/Query/FilteredQueryDescriptor.cs

+13
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ public interface IFilteredQuery : IQuery
1717
[JsonProperty(PropertyName = "filter")]
1818
[JsonConverter(typeof(CompositeJsonConverter<ReadAsTypeConverter<FilterContainer>, CustomJsonConverter>))]
1919
IFilterContainer Filter { get; set; }
20+
21+
[JsonProperty(PropertyName = "boost")]
22+
double? Boost { get; set; }
2023
}
2124

2225
public class FilteredQuery : PlainQuery, IFilteredQuery
@@ -30,6 +33,7 @@ protected override void WrapInContainer(IQueryContainer container)
3033
bool IQuery.IsConditionless { get {return false;}}
3134
public IQueryContainer Query { get; set; }
3235
public IFilterContainer Filter { get; set; }
36+
public double? Boost { get; set; }
3337
}
3438

3539
public class FilteredQueryDescriptor<T> : IFilteredQuery where T : class
@@ -40,6 +44,8 @@ public class FilteredQueryDescriptor<T> : IFilteredQuery where T : class
4044

4145
IFilterContainer IFilteredQuery.Filter { get; set; }
4246

47+
double? IFilteredQuery.Boost { get; set; }
48+
4349
string IQuery.Name { get; set; }
4450

4551
bool IQuery.IsConditionless
@@ -61,6 +67,13 @@ public FilteredQueryDescriptor<T> Name(string name)
6167
Self.Name = name;
6268
return this;
6369
}
70+
71+
public FilteredQueryDescriptor<T> Boost(double boost)
72+
{
73+
Self.Boost = boost;
74+
return this;
75+
}
76+
6477
public FilteredQueryDescriptor<T> Query(Func<QueryDescriptor<T>, QueryContainer> querySelector)
6578
{
6679
querySelector.ThrowIfNull("querySelector");

Diff for: src/Nest/DSL/Query/FunctionScoreQueryDescriptor.cs

+14-1
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,10 @@ public interface IFunctionScoreQuery : IQuery
4747

4848
[JsonProperty(PropertyName = "min_score")]
4949
float? MinScore { get; set; }
50+
51+
[JsonProperty(PropertyName = "boost")]
52+
double? Boost { get; set; }
53+
5054
}
5155

5256
public class FunctionScoreQuery : PlainQuery, IFunctionScoreQuery
@@ -75,6 +79,7 @@ public long? Weight
7579
}
7680

7781
public double? WeightAsDouble { get; set; }
82+
public double? Boost { get; set; }
7883
public float? MinScore { get; set; }
7984
}
8085

@@ -106,8 +111,11 @@ public class FunctionScoreQueryDescriptor<T> : IFunctionScoreQuery where T : cla
106111

107112
// TODO: Remove in 2.0 and change Weight to double
108113
double? IFunctionScoreQuery.WeightAsDouble { get; set; }
114+
109115
float? IFunctionScoreQuery.MinScore { get; set; }
110116

117+
double? IFunctionScoreQuery.Boost { get; set; }
118+
111119
string IQuery.Name { get; set; }
112120

113121
private bool _forcedConditionless = false;
@@ -128,13 +136,18 @@ public FunctionScoreQueryDescriptor<T> ConditionlessWhen(bool isConditionless)
128136
return this;
129137
}
130138

131-
132139
public FunctionScoreQueryDescriptor<T> Name(string name)
133140
{
134141
Self.Name = name;
135142
return this;
136143
}
137144

145+
public FunctionScoreQueryDescriptor<T> Boost(double boost)
146+
{
147+
Self.Boost = boost;
148+
return this;
149+
}
150+
138151
public FunctionScoreQueryDescriptor<T> Query(Func<QueryDescriptor<T>, QueryContainer> querySelector)
139152
{
140153
querySelector.ThrowIfNull("querySelector");

Diff for: src/Nest/DSL/Query/GeoShapeCircleQueryDescriptor.cs

+16
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,17 @@ namespace Nest
1111
public interface IGeoShapeQuery : IFieldNameQuery
1212
{
1313
PropertyPathMarker Field { get; set; }
14+
1415
}
1516

1617
[JsonObject(MemberSerialization = MemberSerialization.OptIn)]
1718
public interface IGeoShapeCircleQuery : IGeoShapeQuery
1819
{
1920
[JsonProperty("shape")]
2021
ICircleGeoShape Shape { get; set; }
22+
23+
[JsonProperty(PropertyName = "boost")]
24+
double? Boost { get; set; }
2125
}
2226

2327
public class GeoShapeCircleQuery : PlainQuery, IGeoShapeCircleQuery
@@ -42,6 +46,8 @@ void IFieldNameQuery.SetFieldName(string fieldName)
4246

4347
public PropertyPathMarker Field { get; set; }
4448

49+
public double? Boost { get; set; }
50+
4551
public ICircleGeoShape Shape { get; set; }
4652
}
4753

@@ -64,10 +70,13 @@ bool IQuery.IsConditionless
6470

6571
string IQuery.Name { get; set; }
6672

73+
double? IGeoShapeCircleQuery.Boost { get; set; }
74+
6775
void IFieldNameQuery.SetFieldName(string fieldName)
6876
{
6977
((IGeoShapeQuery)this).Field = fieldName;
7078
}
79+
7180
PropertyPathMarker IFieldNameQuery.GetFieldName()
7281
{
7382
return ((IGeoShapeQuery)this).Field;
@@ -106,5 +115,12 @@ public GeoShapeCircleQueryDescriptor<T> Radius(string radius)
106115
Self.Shape.Radius = radius;
107116
return this;
108117
}
118+
119+
public GeoShapeCircleQueryDescriptor<T> Boost(double boost)
120+
{
121+
Self.Boost = boost;
122+
return this;
123+
}
124+
109125
}
110126
}

Diff for: src/Nest/DSL/Query/GeoShapeEnvelopeQueryDescriptor.cs

+15
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ public interface IGeoShapeEnvelopeQuery : IGeoShapeQuery
1515
{
1616
[JsonProperty("shape")]
1717
IEnvelopeGeoShape Shape { get; set; }
18+
19+
[JsonProperty(PropertyName = "boost")]
20+
double? Boost { get; set; }
1821
}
1922

2023
public class GeoShapeEnvelopeQuery : PlainQuery, IGeoShapeEnvelopeQuery
@@ -25,6 +28,9 @@ protected override void WrapInContainer(IQueryContainer container)
2528
}
2629

2730
public string Name { get; set; }
31+
32+
public double? Boost { get; set; }
33+
2834
bool IQuery.IsConditionless { get { return false; } }
2935

3036
PropertyPathMarker IFieldNameQuery.GetFieldName()
@@ -50,6 +56,8 @@ public class GeoShapeEnvelopeQueryDescriptor<T> : IGeoShapeEnvelopeQuery where T
5056

5157
IEnvelopeGeoShape IGeoShapeEnvelopeQuery.Shape { get; set; }
5258

59+
double? IGeoShapeEnvelopeQuery.Boost { get; set; }
60+
5361
bool IQuery.IsConditionless
5462
{
5563
get
@@ -64,6 +72,7 @@ void IFieldNameQuery.SetFieldName(string fieldName)
6472
{
6573
Self.Field = fieldName;
6674
}
75+
6776
PropertyPathMarker IFieldNameQuery.GetFieldName()
6877
{
6978
return Self.Field;
@@ -75,6 +84,12 @@ public GeoShapeEnvelopeQueryDescriptor<T> Name(string name)
7584
return this;
7685
}
7786

87+
public GeoShapeEnvelopeQueryDescriptor<T> Boost(double boost)
88+
{
89+
Self.Boost = boost;
90+
return this;
91+
}
92+
7893
public GeoShapeEnvelopeQueryDescriptor<T> OnField(string field)
7994
{
8095
Self.Field = field;

Diff for: src/Nest/DSL/Query/GeoShapeLineStringQueryDescriptor.cs

+17
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ public interface IGeoShapeLineStringQuery : IGeoShapeQuery
1515
{
1616
[JsonProperty("shape")]
1717
ILineStringGeoShape Shape { get; set; }
18+
19+
[JsonProperty(PropertyName = "boost")]
20+
double? Boost { get; set; }
1821
}
1922

2023
public class GeoShapeLineStringQuery : PlainQuery, IGeoShapeLineStringQuery
@@ -25,6 +28,9 @@ protected override void WrapInContainer(IQueryContainer container)
2528
}
2629

2730
public string Name { get; set; }
31+
32+
public double? Boost { get; set; }
33+
2834
bool IQuery.IsConditionless { get { return false; } }
2935

3036
PropertyPathMarker IFieldNameQuery.GetFieldName()
@@ -50,6 +56,8 @@ public class GeoShapeLineStringQueryDescriptor<T> : IGeoShapeLineStringQuery whe
5056

5157
ILineStringGeoShape IGeoShapeLineStringQuery.Shape { get; set; }
5258

59+
double? IGeoShapeLineStringQuery.Boost { get; set; }
60+
5361
bool IQuery.IsConditionless
5462
{
5563
get
@@ -64,6 +72,7 @@ void IFieldNameQuery.SetFieldName(string fieldName)
6472
{
6573
((IGeoShapeQuery)this).Field = fieldName;
6674
}
75+
6776
PropertyPathMarker IFieldNameQuery.GetFieldName()
6877
{
6978
return ((IGeoShapeQuery)this).Field;
@@ -74,6 +83,7 @@ public GeoShapeLineStringQueryDescriptor<T> OnField(string field)
7483
((IGeoShapeQuery)this).Field = field;
7584
return this;
7685
}
86+
7787
public GeoShapeLineStringQueryDescriptor<T> OnField(Expression<Func<T, object>> objectPath)
7888
{
7989
((IGeoShapeQuery)this).Field = objectPath;
@@ -85,6 +95,13 @@ public GeoShapeLineStringQueryDescriptor<T> Name(string name)
8595
Self.Name = name;
8696
return this;
8797
}
98+
99+
public GeoShapeLineStringQueryDescriptor<T> Boost(double boost)
100+
{
101+
Self.Boost = boost;
102+
return this;
103+
}
104+
88105
public GeoShapeLineStringQueryDescriptor<T> Coordinates(IEnumerable<IEnumerable<double>> coordinates)
89106
{
90107
if (Self.Shape == null)

Diff for: src/Nest/DSL/Query/GeoShapeMultiLineStringQueryDescriptor.cs

+16
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ public interface IGeoShapeMultiLineStringQuery : IGeoShapeQuery
1515
{
1616
[JsonProperty("shape")]
1717
IMultiLineStringGeoShape Shape { get; set; }
18+
19+
[JsonProperty(PropertyName = "boost")]
20+
double? Boost { get; set; }
1821
}
1922

2023
public class GeoShapeMultiLineStringQuery : PlainQuery, IGeoShapeMultiLineStringQuery
@@ -25,6 +28,9 @@ protected override void WrapInContainer(IQueryContainer container)
2528
}
2629

2730
public string Name { get; set; }
31+
32+
public double? Boost { get; set; }
33+
2834
bool IQuery.IsConditionless { get { return false; } }
2935

3036
PropertyPathMarker IFieldNameQuery.GetFieldName()
@@ -50,6 +56,8 @@ public class GeoShapeMultiLineStringQueryDescriptor<T> : IGeoShapeMultiLineStrin
5056

5157
IMultiLineStringGeoShape IGeoShapeMultiLineStringQuery.Shape { get; set; }
5258

59+
double? IGeoShapeMultiLineStringQuery.Boost { get; set; }
60+
5361
bool IQuery.IsConditionless
5462
{
5563
get
@@ -64,6 +72,7 @@ void IFieldNameQuery.SetFieldName(string fieldName)
6472
{
6573
((IGeoShapeQuery)this).Field = fieldName;
6674
}
75+
6776
PropertyPathMarker IFieldNameQuery.GetFieldName()
6877
{
6978
return ((IGeoShapeQuery)this).Field;
@@ -75,11 +84,18 @@ public GeoShapeMultiLineStringQueryDescriptor<T> Name(string name)
7584
return this;
7685
}
7786

87+
public GeoShapeMultiLineStringQueryDescriptor<T> Boost(double boost)
88+
{
89+
Self.Boost = boost;
90+
return this;
91+
}
92+
7893
public GeoShapeMultiLineStringQueryDescriptor<T> OnField(string field)
7994
{
8095
((IGeoShapeQuery)this).Field = field;
8196
return this;
8297
}
98+
8399
public GeoShapeMultiLineStringQueryDescriptor<T> OnField(Expression<Func<T, object>> objectPath)
84100
{
85101
((IGeoShapeQuery)this).Field = objectPath;

Diff for: src/Nest/DSL/Query/GeoShapeMultiPointQueryDescriptor.cs

+17
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ public interface IGeoShapeMultiPointQuery : IGeoShapeQuery
1515
{
1616
[JsonProperty("shape")]
1717
IMultiPointGeoShape Shape { get; set; }
18+
19+
[JsonProperty(PropertyName = "boost")]
20+
double? Boost { get; set; }
1821
}
1922

2023
public class GeoShapeMultiPointQuery : PlainQuery, IGeoShapeMultiPointQuery
@@ -25,6 +28,9 @@ protected override void WrapInContainer(IQueryContainer container)
2528
}
2629

2730
public string Name { get; set; }
31+
32+
public double? Boost { get; set; }
33+
2834
bool IQuery.IsConditionless { get { return false; } }
2935

3036
PropertyPathMarker IFieldNameQuery.GetFieldName()
@@ -50,6 +56,8 @@ public class GeoShapeMultiPointQueryDescriptor<T> : IGeoShapeMultiPointQuery whe
5056

5157
IMultiPointGeoShape IGeoShapeMultiPointQuery.Shape { get; set; }
5258

59+
double? IGeoShapeMultiPointQuery.Boost { get; set; }
60+
5361
string IQuery.Name { get; set; }
5462

5563
bool IQuery.IsConditionless
@@ -64,6 +72,7 @@ void IFieldNameQuery.SetFieldName(string fieldName)
6472
{
6573
((IGeoShapeQuery)this).Field = fieldName;
6674
}
75+
6776
PropertyPathMarker IFieldNameQuery.GetFieldName()
6877
{
6978
return ((IGeoShapeQuery)this).Field;
@@ -74,11 +83,19 @@ public GeoShapeMultiPointQueryDescriptor<T> Name(string name)
7483
Self.Name = name;
7584
return this;
7685
}
86+
87+
public GeoShapeMultiPointQueryDescriptor<T> Boost(double boost)
88+
{
89+
Self.Boost = boost;
90+
return this;
91+
}
92+
7793
public GeoShapeMultiPointQueryDescriptor<T> OnField(string field)
7894
{
7995
((IGeoShapeQuery)this).Field = field;
8096
return this;
8197
}
98+
8299
public GeoShapeMultiPointQueryDescriptor<T> OnField(Expression<Func<T, object>> objectPath)
83100
{
84101
((IGeoShapeQuery)this).Field = objectPath;

0 commit comments

Comments
 (0)