Notice: Over the next few months, we're reorganizing the App Engine documentation site to make it easier to find content and better align with the rest of Google Cloud products. The same content will be available, but the navigation will now match the rest of the Cloud products.

Python 2 is no longer supported by the community. We recommend that you migrate Python 2 apps to Python 3.

class RescoringMatchScorer

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.

Caution: **This solution is no longer recommended:** Apps that use this API can only run in the Python 2 runtime and will need to upgrade to a [recommended solution](/appengine/docs/standard/python/migrate-to-python3/migrating-services#migration_paths_for_bundled_services) before migrating to the Python 3 runtime.

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.