Skip to content

Change long to float for Weight #1087

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 12 additions & 5 deletions src/Nest/DSL/Query/FunctionScoreQueryDescriptor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public interface IFunctionScoreQuery : IQuery
IScriptFilter ScriptScore { get; set; }

[JsonProperty(PropertyName = "weight")]
long? Weight { get; set; }
float? Weight { get; set; }
}

public class FunctionScoreQuery : PlainQuery, IFunctionScoreQuery
Expand All @@ -55,7 +55,7 @@ protected override void WrapInContainer(IQueryContainer container)
public float? MaxBoost { get; set; }
public IRandomScoreFunction RandomScore { get; set; }
public IScriptFilter ScriptScore { get; set; }
public long? Weight { get; set; }
public float? Weight { get; set; }
}

public class FunctionScoreQueryDescriptor<T> : IFunctionScoreQuery where T : class
Expand All @@ -74,7 +74,7 @@ public class FunctionScoreQueryDescriptor<T> : IFunctionScoreQuery where T : cla

IScriptFilter IFunctionScoreQuery.ScriptScore { get; set; }

long? IFunctionScoreQuery.Weight { get; set; }
float? IFunctionScoreQuery.Weight { get; set; }

bool IQuery.IsConditionless
{
Expand Down Expand Up @@ -109,6 +109,13 @@ public FunctionScoreQueryDescriptor<T> Functions(params Func<FunctionScoreFuncti

return this;
}

public FunctionScoreQueryDescriptor<T> Functions(FunctionScoreFunction<T>[] functions)
{
((IFunctionScoreQuery)this).Functions = functions;

return this;
}

public FunctionScoreQueryDescriptor<T> ScoreMode(FunctionScoreMode mode)
{
Expand Down Expand Up @@ -149,10 +156,10 @@ public FunctionScoreQueryDescriptor<T> ScriptScore(Action<ScriptFilterDescriptor
return this;
}

public FunctionScoreQueryDescriptor<T> Weight(long weight)
public FunctionScoreQueryDescriptor<T> Weight(float weight)
{
((IFunctionScoreQuery)this).Weight = weight;
return this;
}
}
}
}
8 changes: 4 additions & 4 deletions src/Nest/DSL/Query/Functions/IFunctionScoreFunction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace Nest
public interface IFunctionScoreFunction
{
FilterContainer Filter { get; set; }
long? Weight { get; set; }
float? Weight { get; set; }
}

[JsonObject(MemberSerialization = MemberSerialization.OptIn)]
Expand All @@ -22,7 +22,7 @@ public class FunctionScoreFunction<T> : IFunctionScoreFunction
FilterContainer IFunctionScoreFunction.Filter { get; set; }

[JsonProperty("weight")]
long? IFunctionScoreFunction.Weight { get; set; }
float? IFunctionScoreFunction.Weight { get; set; }

public FunctionScoreFunction<T> Filter(Func<FilterDescriptor<T>, FilterContainer> filterSelector)
{
Expand All @@ -34,10 +34,10 @@ public FunctionScoreFunction<T> Filter(Func<FilterDescriptor<T>, FilterContainer
return this;
}

public FunctionScoreFunction<T> Weight(long weight)
public FunctionScoreFunction<T> Weight(float weight)
{
this.Self.Weight = weight;
return this;
}
}
}
}