Stay organized with collections
Save and categorize content based on your preferences.
publicfinalclassFacetimplementsSerializable
A Facet can be used to categorize a Document. It is not a Field.
Search results can contain facets for the extended result set and their value frequency.
For example, if a search query is related to "wine", then facets could be "color" with values
of "red" and "white", and "year" with values of "2000" and "2005".
[[["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-03 UTC."],[[["\u003cp\u003eA \u003ccode\u003eFacet\u003c/code\u003e is used to categorize a \u003ccode\u003eDocument\u003c/code\u003e in search results, distinct from a \u003ccode\u003eField\u003c/code\u003e, and can be used to provide a value frequency.\u003c/p\u003e\n"],["\u003cp\u003eEach \u003ccode\u003eFacet\u003c/code\u003e has a name and either an atom or a number as its value, with specific length and value limits, respectively.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003eFacet\u003c/code\u003e can be created via static methods \u003ccode\u003ewithAtom\u003c/code\u003e for atom facets or \u003ccode\u003ewithNumber\u003c/code\u003e for number facets, requiring a name and the respective atom or number value.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003eFacet\u003c/code\u003e class provides methods to retrieve the \u003ccode\u003eFacet\u003c/code\u003e's name, atomic value (\u003ccode\u003egetAtom\u003c/code\u003e), and numeric value (\u003ccode\u003egetNumber\u003c/code\u003e), and also overrides methods such as \u003ccode\u003eequals\u003c/code\u003e, \u003ccode\u003ehashCode\u003c/code\u003e and \u003ccode\u003etoString\u003c/code\u003e from \u003ccode\u003eObject\u003c/code\u003e.\u003c/p\u003e\n"]]],[],null,["# Class Facet (2.0.0)\n\n public final class Facet implements Serializable\n\nA `Facet` can be used to categorize a [Document](/appengine/docs/standard/java-gen2/reference/services/bundled/latest/com.google.appengine.api.search.Document). It is not a [Field](/appengine/docs/standard/java-gen2/reference/services/bundled/latest/com.google.appengine.api.search.Field).\n\n\nSearch results can contain facets for the extended result set and their value frequency.\nFor example, if a search query is related to \"wine\", then facets could be \"color\" with values\nof \"red\" and \"white\", and \"year\" with values of \"2000\" and \"2005\".\n\n\nEach facet has a name and exactly one value: atom or number. Facet name lengths are between 1 and\n[com.google.appengine.api.search.checkers.SearchApiLimits#MAXIMUM_NAME_LENGTH](/appengine/docs/standard/java-gen2/reference/services/bundled/latest/com.google.appengine.api.search.checkers.SearchApiLimits#com_google_appengine_api_search_checkers_SearchApiLimits_MAXIMUM_NAME_LENGTH) characters,\nand atoms are\nlimited to [com.google.appengine.api.search.checkers.SearchApiLimits#MAXIMUM_ATOM_LENGTH](/appengine/docs/standard/java-gen2/reference/services/bundled/latest/com.google.appengine.api.search.checkers.SearchApiLimits#com_google_appengine_api_search_checkers_SearchApiLimits_MAXIMUM_ATOM_LENGTH)\ncharacters. Numbers must be between\n[com.google.appengine.api.search.checkers.SearchApiLimits#MINIMUM_NUMBER_VALUE](/appengine/docs/standard/java-gen2/reference/services/bundled/latest/com.google.appengine.api.search.checkers.SearchApiLimits#com_google_appengine_api_search_checkers_SearchApiLimits_MINIMUM_NUMBER_VALUE) and\n[com.google.appengine.api.search.checkers.SearchApiLimits#MAXIMUM_NUMBER_VALUE](/appengine/docs/standard/java-gen2/reference/services/bundled/latest/com.google.appengine.api.search.checkers.SearchApiLimits#com_google_appengine_api_search_checkers_SearchApiLimits_MAXIMUM_NUMBER_VALUE). \n\nInheritance\n-----------\n\n[Object](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html) \\\u003e Facet \n\nImplements\n----------\n\n[Serializable](https://docs.oracle.com/javase/8/docs/api/java/io/Serializable.html) \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### withAtom(String name, String value)\n\n public static Facet withAtom(String name, String value)\n\nCreates and returns an atom facet with the given `name` and `value`.\n\n### withNumber(String name, Double value)\n\n public static Facet withNumber(String name, Double value)\n\nCreates and returns a number facet with the given `name` and `value`.\n\nMethods\n-------\n\n### equals(Object object)\n\n public boolean equals(Object object)\n\n**Overrides** \n[Object.equals(Object)](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#equals-java.lang.Object-)\n\n### getAtom()\n\n public String getAtom()\n\nReturns the atomic value of the facet. Returns null if the value is not atomic.\n\n### getName()\n\n public String getName()\n\nReturns the name of the facet.\n\n### getNumber()\n\n public Double getNumber()\n\nReturns the numeric value of the facet. Returns null if the value is not numeric.\n\n### hashCode()\n\n public int hashCode()\n\n**Overrides** \n[Object.hashCode()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#hashCode--)\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--)"]]