Skip to content

/match returns results below threshold unless deprecated cutoff is explicitly passed #940

@santialbo

Description

@santialbo

When calling /match with a threshold higher than the default, the response still includes results scored below threshold unless the deprecated cutoff parameter is explicitly provided and set to the same value.

threshold: float = Query(
    default=settings.SCORE_THRESHOLD,
    title="Score threshold for results to be considered matches",
),
cutoff: float = Query(
    deprecated=True,
    default=settings.SCORE_THRESHOLD,
    title="Deprecated, use `threshold` instead. Lower bound of score for results to be returned at all",
),
...
cutoff = min(cutoff, threshold)
...
total, scored = await score_results(
    algorithm_type,
    entity,
    ents,
    threshold=threshold,
    cutoff=cutoff,
    limit=limit,
    config=ScoringConfig(weights=match.weights, config=match.config),
)

As a result, a higher threshold does not tighten the lower-bound filter unless cutoff is also raised. Given that cutoff is marked deprecated, this is surprising behavior.

Expected behavior
Setting a higher threshold should be sufficient to prevent results below that threshold from appearing in the response, even if cutoff is not passed.

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