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:
a new MatchScorer.Builder. Set the parameters for scorer
on the Builder, and use the Builder#build() method
to create a concrete instance of MatchScorer
[[["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-09-04 UTC."],[[["\u003cp\u003eMatchScorer assigns document scores based on the frequency of terms in TextFields and HTMLFields.\u003c/p\u003e\n"],["\u003cp\u003eAdding a MatchScorer to SortOptions sorts documents in descending order by score, resulting in positive scores.\u003c/p\u003e\n"],["\u003cp\u003eTo sort in ascending order, a SortExpression must be added that utilizes the SCORE_FIELD_NAME with the direction set to ASCENDING, which will produce negative scores.\u003c/p\u003e\n"],["\u003cp\u003eMatchScorer provides a static \u003ccode\u003enewBuilder()\u003c/code\u003e method to create and configure a MatchScorer.Builder.\u003c/p\u003e\n"],["\u003cp\u003eMatchScorer class inherits from java.lang.Object, inheriting functions such as clone, equals, and toString, among other functions.\u003c/p\u003e\n"]]],[],null,["# Class MatchScorer (2.0.0)\n\n public class MatchScorer\n\nAssigns a document score based on frequency of terms in TextFields and HTMLFields.\n\nIf you add a MatchScorer to a SortOptions as in the following code: \n\n\n SortOptions sortOptions = SortOptions.newBuilder()\n .setMatchScorer(MatchScorer.newBuilder())\n .build();\n \nthen this will sort the documents in descending score order. The scores will be positive. If you\nwant to sort in ascending order, then use the following code: \n\n\n SortOptions sortOptions = SortOptions.newBuilder()\n .setMatchScorer(MatchScorer.newBuilder())\n .addSortExpression(\n SortExpression.newBuilder()\n .setExpression(SortExpression.SCORE_FIELD_NAME)\n .setDirection(SortExpression.SortDirection.ASCENDING)\n .setDefaultValueNumeric(0.0))\n .build();\n \nIn this example, the score will be negative. \n\nInheritance\n-----------\n\n[java.lang.Object](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html) \\\u003e MatchScorer \n\nInherited Members\n-----------------\n\n[Object.clone()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#clone--) \n[Object.equals(Object)](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#equals-java.lang.Object-) \n[Object.finalize()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#finalize--) \n[Object.getClass()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#getClass--) \n[Object.hashCode()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#hashCode--) \n[Object.notify()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#notify--) \n[Object.notifyAll()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#notifyAll--) \n[Object.toString()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#toString--) \n[Object.wait()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait--) \n[Object.wait(long)](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait-long-) \n[Object.wait(long,int)](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait-long-int-)\n\nStatic Methods\n--------------\n\n### newBuilder()\n\n public static MatchScorer.Builder newBuilder()\n\nCreates and returns a MatchScorer Builder.\n\nMethods\n-------\n\n### toString()\n\n public String toString()\n\n**Overrides** \n[Object.toString()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#toString--)"]]