Skip to content

Commit 9f3977c

Browse files
support legacy FieldValueFactor name for FieldValueFactorScore
1 parent 28a98e2 commit 9f3977c

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed

elasticsearch_dsl/function.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,10 +134,14 @@ class RandomScore(ScoreFunction):
134134
name = "random_score"
135135

136136

137-
class FieldValueFactor(ScoreFunction):
137+
class FieldValueFactorScore(ScoreFunction):
138138
name = "field_value_factor"
139139

140140

141+
class FieldValueFactor(FieldValueFactorScore): # alias of the above
142+
pass
143+
144+
141145
class Linear(ScoreFunction):
142146
name = "linear"
143147

elasticsearch_dsl/interfaces.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ class FunctionScoreContainer(AttrDict[Any]):
173173
exp: Union["f.DecayFunction", "DefaultType"]
174174
gauss: Union["f.DecayFunction", "DefaultType"]
175175
linear: Union["f.DecayFunction", "DefaultType"]
176-
field_value_factor: Union["f.FieldValueFactor", "DefaultType"]
176+
field_value_factor: Union["f.FieldValueFactorScore", "DefaultType"]
177177
random_score: Union["f.RandomScore", "DefaultType"]
178178
script_score: Union["f.ScriptScore", "DefaultType"]
179179
filter: Union[Query, "DefaultType"]
@@ -185,7 +185,7 @@ def __init__(
185185
exp: Union["f.DecayFunction", "DefaultType"] = DEFAULT,
186186
gauss: Union["f.DecayFunction", "DefaultType"] = DEFAULT,
187187
linear: Union["f.DecayFunction", "DefaultType"] = DEFAULT,
188-
field_value_factor: Union["f.FieldValueFactor", "DefaultType"] = DEFAULT,
188+
field_value_factor: Union["f.FieldValueFactorScore", "DefaultType"] = DEFAULT,
189189
random_score: Union["f.RandomScore", "DefaultType"] = DEFAULT,
190190
script_score: Union["f.ScriptScore", "DefaultType"] = DEFAULT,
191191
filter: Union[Query, "DefaultType"] = DEFAULT,

utils/generator.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -211,8 +211,6 @@ def get_python_type(self, schema_type):
211211
return '"wrappers.Range[Any]"', None
212212
elif schema_type["name"]["name"].endswith("ScoreFunction"):
213213
name = schema_type["name"]["name"][:-8]
214-
if name == "FieldValueFactorScore":
215-
name = "FieldValueFactor" # Python DSL uses different name
216214
return f'"f.{name}"', None
217215
elif schema_type["name"]["name"].endswith("DecayFunction"):
218216
return '"f.DecayFunction"', None

0 commit comments

Comments
 (0)