Skip to content

Commit 59aa5d5

Browse files
committed
Merge pull request #1305 from elastic/feature/function-score-mark-conditionless
ConditionlessWhen on function_score query
2 parents 3bdca62 + ba6b2b5 commit 59aa5d5

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

src/Nest/DSL/Query/FunctionScoreQueryDescriptor.cs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,17 +98,26 @@ public class FunctionScoreQueryDescriptor<T> : IFunctionScoreQuery where T : cla
9898

9999
string IQuery.Name { get; set; }
100100

101+
private bool _forcedConditionless = false;
102+
101103
bool IQuery.IsConditionless
102104
{
103105
get
104106
{
105-
return (Self.Query == null || Self.Query.IsConditionless)
107+
return _forcedConditionless || ((Self.Query == null || Self.Query.IsConditionless)
106108
&& Self.RandomScore == null
107109
&& Self.ScriptScore == null
108-
&& !Self.Functions.HasAny();
110+
&& !Self.Functions.HasAny());
109111
}
110112
}
111113

114+
public FunctionScoreQueryDescriptor<T> ConditionlessWhen(bool isConditionless)
115+
{
116+
this._forcedConditionless = isConditionless;
117+
return this;
118+
}
119+
120+
112121
public FunctionScoreQueryDescriptor<T> Name(string name)
113122
{
114123
Self.Name = name;

0 commit comments

Comments
 (0)