Python 2.7 has reached end of support
and will be
deprecated
on January 31, 2026. After deprecation, you won't be able to deploy Python 2.7
applications, even if your organization previously used an organization policy to
re-enable deployments of legacy runtimes. Your existing Python
2.7 applications will continue to run and receive traffic after their
deprecation date. We recommend that
you
migrate to the latest supported version of Python.
class RescoringMatchScorer
Stay organized with collections
Save and categorize content based on your preferences.
Class RescoringMatchScorer
allows you to sort documents based on the quality
of query match. It is similar to a
MatchScorer
but uses a more complex scoring algorithm based on match term frequency and other factors like field type.
Please be aware that this algorithm is continually refined and can change over time without notice. This means that the ordering
of search results that use this scorer can also change without notice.
To use a RescoringMatchScorer
, add it to the SortOptions
as in the following code:
sort_opts = search.SortOptions(match_scorer=search.RescoringMatchScorer())
This sorts the documents in descending score order. The scores will be
positive.
If you want to sort in ascending order, then use the following code:
sort_opts = search.SortOptions(match_scorer=search.RescoringMatchScorer(),
expressions=[search.SortExpression(
expression='_score', direction=search.SortExpression.ASCENDING,
default_value=0.0)])
The scores in this case will be negative.
RescoringMatchScorer
is defined in the google.appengine.api.search
module.
Constructor
The constructor for class RescoringMatchScorer
is defined as follows:
- class RescoringMatchScorer()
Assigns a document score to search results representing how well they match the query, base on frequency of terms in the document and weighted by doc parts.
Result value
A new instance of class RescoringMatchScorer
.
Exceptions
- TypeError
If any of the parameters have an invalid type, or an unknown attribute is passed.
- ValueError
If any parameter has an invalid value.
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-08-04 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-04 UTC."],[[["`RescoringMatchScorer` sorts documents by query match quality using a complex algorithm that considers term frequency and field type."],["The scoring algorithm used by `RescoringMatchScorer` is subject to change, potentially impacting the order of search results."],["Documents are sorted in descending order by default using `RescoringMatchScorer`, resulting in positive scores."],["To sort in ascending order, use `SortExpression` with the `_score` expression and `ASCENDING` direction, which results in negative scores."],["`RescoringMatchScorer` is available in first-generation runtimes and can be used when upgrading to corresponding second-generation runtimes."]]],[]]