diff --git a/CHANGELOG.md b/CHANGELOG.md index 7f69025da0..8d1824293b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) - As part of [efforts to re-generate the client](https://github.com/opensearch-project/opensearch-net/pulls?q=is%3Apr+label%3Acode-gen+is%3Aclosed) from our [OpenAPI specification](https://github.com/opensearch-project/opensearch-api-specification) there have been numerous corrections and changes that resulted in breaking changes. Please refer to [UPGRADING.md](UPGRADING.md) for a complete list of these breakages and any relevant guidance for upgrading to this version of the client. ### Added +- Added support for `MinScore` on `ScriptScoreQuery` ([#624](https://github.com/opensearch-project/opensearch-net/pull/624)) - Added support for the `Cat.PitSegments` and `Cat.SegmentReplication` APIs ([#527](https://github.com/opensearch-project/opensearch-net/pull/527)) ### Removed diff --git a/src/OpenSearch.Client/QueryDsl/Specialized/ScriptScore/ScriptScoreQuery.cs b/src/OpenSearch.Client/QueryDsl/Specialized/ScriptScore/ScriptScoreQuery.cs index b3a852de42..a5e1851988 100644 --- a/src/OpenSearch.Client/QueryDsl/Specialized/ScriptScore/ScriptScoreQuery.cs +++ b/src/OpenSearch.Client/QueryDsl/Specialized/ScriptScore/ScriptScoreQuery.cs @@ -52,6 +52,12 @@ public interface IScriptScoreQuery : IQuery /// [DataMember(Name = "script")] IScript Script { get; set; } + + /// + /// The score above which documents will be returned + /// + [DataMember(Name = "min_score")] + double? MinScore { get; set; } } /// @@ -63,6 +69,9 @@ public class ScriptScoreQuery : QueryBase, IScriptScoreQuery /// public IScript Script { get; set; } + /// + public double? MinScore { get; set; } + protected override bool Conditionless => IsConditionless(this); internal override void InternalWrapInContainer(IQueryContainer c) => c.ScriptScore = this; @@ -94,6 +103,8 @@ public class ScriptScoreQueryDescriptor IScript IScriptScoreQuery.Script { get; set; } + double? IScriptScoreQuery.MinScore { get; set; } + /// public ScriptScoreQueryDescriptor Query(Func, QueryContainer> selector) => Assign(selector, (a, v) => a.Query = v?.Invoke(new QueryContainerDescriptor())); @@ -101,5 +112,9 @@ public ScriptScoreQueryDescriptor Query(Func, Que /// public ScriptScoreQueryDescriptor Script(Func selector) => Assign(selector, (a, v) => a.Script = v?.Invoke(new ScriptDescriptor())); - } + + /// + public ScriptScoreQueryDescriptor MinScore(double? minScore) => Assign(minScore, (a, v) => a.MinScore = v); + + } } diff --git a/tests/Tests/QueryDsl/Specialized/ScriptScore/ScriptScoreQueryUsageTests.cs b/tests/Tests/QueryDsl/Specialized/ScriptScore/ScriptScoreQueryUsageTests.cs index ff4ec9a21b..d7ed178cab 100644 --- a/tests/Tests/QueryDsl/Specialized/ScriptScore/ScriptScoreQueryUsageTests.cs +++ b/tests/Tests/QueryDsl/Specialized/ScriptScore/ScriptScoreQueryUsageTests.cs @@ -79,6 +79,7 @@ public ScriptScoreQueryUsageTests(ReadOnlyCluster i, EndpointUsage usage) : base { Name = "named_query", Boost = 1.1, + MinScore = 1.2, Query = new NumericRangeQuery { Field = Infer.Field(f => f.NumberOfCommits), @@ -102,6 +103,7 @@ public ScriptScoreQueryUsageTests(ReadOnlyCluster i, EndpointUsage usage) : base { _name = "named_query", boost = 1.1, + min_score = 1.2, query = new { range = new @@ -130,6 +132,7 @@ protected override QueryContainer QueryFluent(QueryContainerDescriptor .ScriptScore(sn => sn .Name("named_query") .Boost(1.1) + .MinScore(1.2) .Query(qq => qq .Range(r => r .Field(f => f.NumberOfCommits)