Skip to content

ScoreFunction is not documented - Unknown query [function_score] #1561

Open
@andyhmltn

Description

@andyhmltn

Hello,

I'm trying to implement a function score using elasticsearch-dsl-py. So I'm trying to use ScoreFunction like so:

score_function = ScoreFunction(weight=5, filter=Range(linked_user__last_login={'gt': 'now-1y'}))

However if I call to_dict on that method I can see the dictionary returned has None as a key which seems wrong:

{None: {},
 'filter': {'range': {'linked_user.last_login': {'gt': 'now-1y'}}},
 'weight': 5}

Then if I try to use that with my search like so (after a hint from here: #608 (comment)):

search.query = FunctionScore(query=search.query, functions=[score_function])

and call search.execute() I get:

RequestError(400, 'parsing_exception', 'unknown query [function_score] did you mean any of [random_score, script_score]?')

What's the cause for this? The only documentation I can find on this is in issue #608 and using the example results in the following error.

Thank you!

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions