Skip to content

Commit 8d26def

Browse files
committed
Add missing max_boost parameter to function score query
1 parent 84781b5 commit 8d26def

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

src/Nest/DSL/Query/FunctionScoreQueryDescriptor.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ public interface IFunctionScoreQuery : IQuery
2727
[JsonConverter(typeof (StringEnumConverter))]
2828
FunctionBoostMode? BoostMode { get; set; }
2929

30+
[JsonProperty("max_boost")]
31+
float? MaxBoost { get; set; }
32+
3033
[JsonProperty(PropertyName = "random_score")]
3134
IRandomScoreFunction RandomScore { get; set; }
3235

@@ -46,6 +49,7 @@ protected override void WrapInContainer(IQueryContainer container)
4649
public IQueryContainer Query { get; set; }
4750
public FunctionScoreMode? ScoreMode { get; set; }
4851
public FunctionBoostMode? BoostMode { get; set; }
52+
public float? MaxBoost { get; set; }
4953
public IRandomScoreFunction RandomScore { get; set; }
5054
public IScriptFilter ScriptScore { get; set; }
5155
}
@@ -60,6 +64,8 @@ public class FunctionScoreQueryDescriptor<T> : IFunctionScoreQuery where T : cla
6064

6165
FunctionBoostMode? IFunctionScoreQuery.BoostMode { get; set; }
6266

67+
float? IFunctionScoreQuery.MaxBoost { get; set; }
68+
6369
IRandomScoreFunction IFunctionScoreQuery.RandomScore { get; set; }
6470

6571
IScriptFilter IFunctionScoreQuery.ScriptScore { get; set; }
@@ -110,6 +116,12 @@ public FunctionScoreQueryDescriptor<T> BoostMode(FunctionBoostMode mode)
110116
return this;
111117
}
112118

119+
public FunctionScoreQueryDescriptor<T> MaxBoost(float maxBoost)
120+
{
121+
((IFunctionScoreQuery)this).MaxBoost = maxBoost;
122+
return this;
123+
}
124+
113125
public FunctionScoreQueryDescriptor<T> RandomScore(int? seed = null)
114126
{
115127
((IFunctionScoreQuery)this).RandomScore = new RandomScoreFunction();

src/Tests/Nest.Tests.Unit/QueryParsers/Queries/FunctionScoreQueryTests.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ public void FunctionScore_Deserializes()
1515
f=>f.FunctionScore,
1616
f=>f.FunctionScore(fq=>fq
1717
.BoostMode(FunctionBoostMode.Average)
18+
.MaxBoost(0.95f)
1819
.Functions(
1920
ff => ff.Gauss(x => x.StartedOn, d => d.Scale("42w")),
2021
ff => ff.Linear(x => x.FloatValue, d => d.Scale("0.3")),
@@ -33,6 +34,7 @@ public void FunctionScore_Deserializes()
3334
);
3435

3536
q.BoostMode.Should().Be(FunctionBoostMode.Average);
37+
q.MaxBoost.Should().Be(0.95f);
3638
q.RandomScore.Should().NotBeNull();
3739
q.RandomScore.Seed.Should().Be(1337);
3840
q.ScoreMode.Should().Be(FunctionScoreMode.First);

0 commit comments

Comments
 (0)