Skip to content

Missing weight parameter in function score query for certain functions #356

Open
@Ekimik

Description

@Ekimik

Hi,
I am using version 7.2.1 of your library and I have just noticed that I cannot add weight attribute when I am adding field value factor function. Is this intentional? I can see $weight parameter in ONGR\ElasticsearchDSL\Query\Compound\FunctionScoreQuery::addDecayFunction method.

Methods

  • ONGR\ElasticsearchDSL\Query\Compound\FunctionScoreQuery::addFieldValueFactorFunction
  • ONGR\ElasticsearchDSL\Query\Compound\FunctionScoreQuery::addRandomFunction
  • ONGR\ElasticsearchDSL\Query\Compound\FunctionScoreQuery::addScriptScoreFunction

on the other hand do not have this parameter.

As far as I know, you can add weight to any function supported by function score query, see documentation

Because scores can be on different scales (for example, between 0 and 1 for decay functions but arbitrary for field_value_factor) and also because sometimes a different impact of functions on the score is desirable, the score of each function can be adjusted with a user defined weight. The weight can be defined per function in the functions array (example above) and is multiplied with the score computed by the respective function.

I have also noticed that there is method ONGR\ElasticsearchDSL\Query\Compound\FunctionScoreQuery::addSimpleFunction, is this the way I should use to add weight?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions