# Class MatchScorer (5.0.3)

    public class MatchScorer

Assigns a document score based on frequency of terms in TextFields and HTMLFields.

If you add a MatchScorer to a SortOptions as in the following code:


      SortOptions sortOptions = SortOptions.newBuilder()
          .setMatchScorer(MatchScorer.newBuilder())
          .build();
     
then this will sort the documents in descending score order. The scores will be positive. If you
want to sort in ascending order, then use the following code:


       SortOptions sortOptions = SortOptions.newBuilder()
           .setMatchScorer(MatchScorer.newBuilder())
           .addSortExpression(
               SortExpression.newBuilder()
                   .setExpression(SortExpression.SCORE_FIELD_NAME)
                   .setDirection(SortExpression.SortDirection.ASCENDING)
                   .setDefaultValueNumeric(0.0))
           .build();
     
In this example, the score will be negative.

## Inheritance

[java.lang.Object](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html) \> MatchScorer

## Inherited Members

[Object.clone()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#clone--) [Object.equals(Object)](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#equals-java.lang.Object-) [Object.finalize()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#finalize--) [Object.getClass()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#getClass--) [Object.hashCode()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#hashCode--) [Object.notify()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#notify--) [Object.notifyAll()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#notifyAll--) [Object.toString()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#toString--) [Object.wait()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait--) [Object.wait(long)](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait-long-) [Object.wait(long,int)](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait-long-int-)

## Static Methods

### newBuilder()

    public static MatchScorer.Builder newBuilder()

Creates and returns a MatchScorer Builder.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/appengine/docs/standard/java-gen2/reference/services/bundled/latest/com.google.appengine.api.search.MatchScorer.Builder` | a new [MatchScorer.Builder](https://docs.cloud.google.com/appengine/docs/standard/java-gen2/reference/services/bundled/latest/com.google.appengine.api.search.MatchScorer.Builder). Set the parameters for scorer on the Builder, and use the Builder#build() method to create a concrete instance of MatchScorer |

## Methods

### toString()

    public String toString()

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` |   |

**Overrides** [Object.toString()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#toString--)