Skip to content

Commit

Permalink
support legacy FieldValueFactor name for FieldValueFactorScore
Browse files Browse the repository at this point in the history
  • Loading branch information
miguelgrinberg committed Sep 5, 2024
1 parent 89432a7 commit aca1d1b
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
6 changes: 5 additions & 1 deletion elasticsearch_dsl/function.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,10 +134,14 @@ class RandomScore(ScoreFunction):
name = "random_score"


class FieldValueFactor(ScoreFunction):
class FieldValueFactorScore(ScoreFunction):
name = "field_value_factor"


class FieldValueFactor(FieldValueFactorScore): # alias of the above
pass


class Linear(ScoreFunction):
name = "linear"

Expand Down
4 changes: 2 additions & 2 deletions elasticsearch_dsl/interfaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ class FunctionScoreContainer(AttrDict[Any]):
exp: Union["f.DecayFunction", "DefaultType"]
gauss: Union["f.DecayFunction", "DefaultType"]
linear: Union["f.DecayFunction", "DefaultType"]
field_value_factor: Union["f.FieldValueFactor", "DefaultType"]
field_value_factor: Union["f.FieldValueFactorScore", "DefaultType"]
random_score: Union["f.RandomScore", "DefaultType"]
script_score: Union["f.ScriptScore", "DefaultType"]
filter: Union[Query, "DefaultType"]
Expand All @@ -185,7 +185,7 @@ def __init__(
exp: Union["f.DecayFunction", "DefaultType"] = DEFAULT,
gauss: Union["f.DecayFunction", "DefaultType"] = DEFAULT,
linear: Union["f.DecayFunction", "DefaultType"] = DEFAULT,
field_value_factor: Union["f.FieldValueFactor", "DefaultType"] = DEFAULT,
field_value_factor: Union["f.FieldValueFactorScore", "DefaultType"] = DEFAULT,
random_score: Union["f.RandomScore", "DefaultType"] = DEFAULT,
script_score: Union["f.ScriptScore", "DefaultType"] = DEFAULT,
filter: Union[Query, "DefaultType"] = DEFAULT,
Expand Down
2 changes: 0 additions & 2 deletions utils/generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,8 +211,6 @@ def get_python_type(self, schema_type):
return '"wrappers.Range[Any]"', None
elif schema_type["name"]["name"].endswith("ScoreFunction"):
name = schema_type["name"]["name"][:-8]
if name == "FieldValueFactorScore":
name = "FieldValueFactor" # Python DSL uses different name
return f'"f.{name}"', None
elif schema_type["name"]["name"].endswith("DecayFunction"):
return '"f.DecayFunction"', None
Expand Down

0 comments on commit aca1d1b

Please sign in to comment.