Class Field (2.0.0)

public final class Field implements Serializable

Represents a field of a Document, which is a name, an optional locale, and at most one value: text, HTML, atom, date, GeoPoint, untokenizedPrefix, tokenizedPrefix or vector. Field name lengths are between 1 and com.google.appengine.api.search.checkers.SearchApiLimits#MAXIMUM_NAME_LENGTH characters, and text and HTML values are limited to com.google.appengine.api.search.checkers.SearchApiLimits#MAXIMUM_TEXT_LENGTH. Atoms are limited to com.google.appengine.api.search.checkers.SearchApiLimits#MAXIMUM_ATOM_LENGTH characters, both prefix types are limited to com.google.appengine.api.search.checkers.SearchApiLimits#MAXIMUM_PREFIX_LENGTH . Vector field size is limited to com.google.appengine.api.search.checkers.SearchApiLimits#VECTOR_FIELD_MAX_SIZE and dates must not have a time component.

There are 5 types of text fields, ATOM, TEXT, HTML, UNTOKENIZED_PREFIX, and TOKENIZED_PREFIX. Atom fields when queried, are checked for equality. For example, if you add a field with name code and an ATOM value of "928A 33B-1", then query code:"928A 33B-1" would match the document with this field, while query code:928A would not. TEXT fields, unlike ATOM, match both on equality or if any token extracted from the original field matches. Thus if code field had the value set with Field.Builder#setText(String) method, both queries would match. HTML fields have HTML tags stripped before tokenization. Untokenized prefix fields match queries that are prefixes containing the contiguous starting characters of the whole field. For example if the field was "the quick brown fox", the query "the qui" would match whereas "th qui" would not. On the other hand, Tokenized prefix fields match if the query terms are prefixes of individual terms in the field. If the query is a phrase of terms, the ordering of the terms will matter. For example if the field is "the quick brown fox", the query "th qui bro" would match whereas "bro qui the" would not. Vector fields are only used to compute the dot product between a given constant vector and the provided vector field for sorting and field expressions only. for example, if a 3d vector is named "scores" and has a value of (1,2,3) then the expression dot(scores, vector(3,2,1)) will be evaluated to 10.

Inheritance

Object > Field

Implements

Serializable

Static Methods

newBuilder()

public static Field.Builder newBuilder()

Creates a field builder.

Returns
Type Description
Field.Builder

a new builder for creating fields

Methods

equals(Object object)

public boolean equals(Object object)
Parameter
Name Description
object Object
Returns
Type Description
boolean
Overrides

getAtom()

public String getAtom()
Returns
Type Description
String

the atomic value of the field. Can be null

getDate()

public Date getDate()
Returns
Type Description
Date

the date value of the field. Can be null

getGeoPoint()

public GeoPoint getGeoPoint()
Returns
Type Description
GeoPoint

the GeoPoint value of the field. Can be null

getHTML()

public String getHTML()
Returns
Type Description
String

the HTML value of the field. Can be null

getLocale()

public Locale getLocale()
Returns
Type Description
Locale

the locale the field value is written in. Can be null. If none is given the locale of the document will be used

getName()

public String getName()
Returns
Type Description
String

the name of the field

getNumber()

public Double getNumber()
Returns
Type Description
Double

the numeric value of the field. Can be null

getText()

public String getText()
Returns
Type Description
String

the text value of the field. Can be null

getTokenizedPrefix()

public String getTokenizedPrefix()
Returns
Type Description
String

the String value of the tokenized prefix field. Can be null

getType()

public Field.FieldType getType()
Returns
Type Description
Field.FieldType

the type of value of the field. Can be null

getUntokenizedPrefix()

public String getUntokenizedPrefix()
Returns
Type Description
String

the String value of the untokenized prefix field. Can be null

getVector()

public List<Double> getVector()
Returns
Type Description
List<Double>

the vector value of the field.

hashCode()

public int hashCode()
Returns
Type Description
int
Overrides

toString()

public String toString()
Returns
Type Description
String
Overrides