The builder class forGenericDocument
.
Public Constructor Summary
Builder(GenericDocument
document)
Creates a new
GenericDocument.Builder from the given GenericDocument.
|
Public Method Summary
GenericDocument |
build()
Builds the
GenericDocument
object.
|
BuilderType | |
BuilderType |
setCreationTimestampMillis(long creationTimestampMillis)
Sets the creation timestamp of the
GenericDocument ,
in milliseconds.
|
BuilderType | |
BuilderType |
setNamespace(Stringnamespace)
Sets the app-defined namespace this document resides in, changing the value
provided in the constructor.
|
BuilderType |
setPropertyBoolean(Stringname,
boolean... values)
Sets one or multiple
boolean values for a property, replacing its
previous values.
|
BuilderType |
setPropertyBytes(Stringname,
byte... values)
Sets one or multiple
byte[] for a property, replacing its previous
values.
|
BuilderType |
setPropertyDocument(Stringname,
GenericDocument...
values)
Sets one or multiple
GenericDocument
values for a property, replacing its previous values.
|
BuilderType |
setPropertyDouble(Stringname,
double... values)
Sets one or multiple
double values for a property, replacing its
previous values.
|
BuilderType |
setPropertyLong(Stringname,
long... values)
Sets one or multiple
long values for a property, replacing its
previous values.
|
BuilderType |
setPropertyString(Stringname,
String...
values)
Sets one or multiple
String values for a property, replacing its
previous values.
|
BuilderType |
setSchemaType(StringschemaType)
Sets the schema type of this document, changing the value provided in the
constructor.
|
BuilderType |
setScore(int score)
Sets the score of the
GenericDocument .
|
BuilderType |
setTtlMillis(long ttlMillis)
Sets the TTL (time-to-live) of the
GenericDocument ,
in milliseconds.
|
Inherited Method Summary
Public Constructors
publicBuilder(Stringnamespace,Stringid,String schemaType)
Creates a newGenericDocument.Builder
.
Document IDs are unique within a namespace.
The number of namespaces per app should be kept small for efficiency reasons.
Parameters
namespace | the namespace to set for theGenericDocument . |
---|---|
id | the unique identifier for theGenericDocument
in its namespace. |
schemaType | theAppSearchSchema
type of theGenericDocument .
The providedschemaType must be defined using
AppSearchClient.setSchema(SetSchemaRequest, String) prior to inserting a
document of thisschemaType into the AppSearch index using
AppSearchClient.put(PutDocumentsRequest, String) .Otherwise, the
document will be rejected by
AppSearchClient.put(PutDocumentsRequest, String) with result code
AppSearchResult.RESULT_NOT_FOUND . |
publicBuilder(GenericDocument document)
Creates a newGenericDocument.Builder
from the given GenericDocument.
The GenericDocument is deep copied, that is, it changes to a new GenericDocument returned by this function and will NOT affect the original GenericDocument.
Public Methods
publicGenericDocument build()
Builds theGenericDocument
object.
public BuilderTypeclearProperty(Stringname)
Clears the value for the property with the given name.
Note that this method does not support property paths.
You should check for the existence of the property in
GenericDocument.getPropertyNames()
if you need to make sure the property
being cleared actually exists.
If the string passed is an invalid or nonexistent property, no error message or behavior will be observed.
Parameters
name | The name of the property to clear. |
---|
public BuilderTypesetCreationTimestampMillis(long creationTimestampMillis)
Sets the creation timestamp of theGenericDocument
,
in milliseconds.
This should be set using a value obtained from theSystem.currentTimeMillis()
time base.
If this method is not called, this will be set to the time the object is built.
Parameters
creationTimestampMillis | a creation timestamp in milliseconds. |
---|
public BuilderTypesetId(Stringid)
Sets the ID of this document, changing the value provided in the constructor. No special values are reserved or understood by the infrastructure.
Document IDs are unique within the combination of package, database, and namespace.
Setting a document with a duplicate id will overwrite the original document with the new document, enforcing uniqueness within the above constraint.
public BuilderTypesetNamespace(Stringnamespace)
Sets the app-defined namespace this document resides in, changing the value provided in the constructor. No special values are reserved or understood by the infrastructure.
Document IDs are unique within a namespace.
The number of namespaces per app should be kept small for efficiency reasons.
public BuilderTypesetPropertyBoolean(Stringname, boolean... values)
Sets one or multipleboolean
values for a property, replacing its
previous values.
Parameters
name | the name associated with thevalues .Must match the name for this
property as given in
AppSearchSchema.PropertyConfig.getName() . |
---|---|
values | theboolean values of the property. |
Throws
IllegalArgumentException | if the name is empty ornull . |
---|
public BuilderTypesetPropertyBytes(Stringname, byte... values)
Sets one or multiplebyte[]
for a property, replacing its previous
values.
Parameters
name | the name associated with thevalues .Must match the name for this
property as given in
AppSearchSchema.PropertyConfig.getName() . |
---|---|
values | thebyte[] of the property. |
Throws
IllegalArgumentException | if no values are provided, or if a passed inbyte[] is
null ,or if name is empty. |
---|
public BuilderTypesetPropertyDocument(Stringname,GenericDocument... values)
Sets one or multipleGenericDocument
values for a property, replacing its previous values.
Parameters
name | the name associated with thevalues .Must match the name for this
property as given in
AppSearchSchema.PropertyConfig.getName() . |
---|---|
values | theGenericDocument
values of the property. |
Throws
IllegalArgumentException | if no values are provided, or if a passed inGenericDocument
isnull ,or if name is empty. |
---|
public BuilderTypesetPropertyDouble(Stringname, double... values)
Sets one or multipledouble
values for a property, replacing its
previous values.
Parameters
name | the name associated with thevalues .Must match the name for this
property as given in
AppSearchSchema.PropertyConfig.getName() . |
---|---|
values | thedouble values of the property. |
Throws
IllegalArgumentException | if the name is empty ornull . |
---|
public BuilderTypesetPropertyLong(Stringname, long... values)
Sets one or multiplelong
values for a property, replacing its previous
values.
Parameters
name | the name associated with thevalues .Must match the name for this
property as given in
AppSearchSchema.PropertyConfig.getName() . |
---|---|
values | thelong values of the property. |
Throws
IllegalArgumentException | if the name is empty ornull . |
---|
public BuilderTypesetPropertyString(Stringname,String...values)
Sets one or multipleString
values for a property, replacing its
previous values.
Parameters
name | the name associated with thevalues .Must match the name for this
property as given in
AppSearchSchema.PropertyConfig.getName() . |
---|---|
values | theString values of the property. |
Throws
IllegalArgumentException | if no values are provided, or if a passed inString is
null or "". |
---|
public BuilderTypesetSchemaType(String schemaType)
Sets the schema type of this document, changing the value provided in the constructor.
To successfully index a document, the schema type must match the name of an
AppSearchSchema
object previously provided to
AppSearchClient.setSchema(SetSchemaRequest, String)
.
public BuilderTypesetScore(int score)
Sets the score of theGenericDocument
.
The score is a query-independent measure of the document's quality, relative to
otherGenericDocument
objects of the sameAppSearchSchema
type.
Results may be sorted by score using
SearchSpec.Builder.setRankingStrategy(int)
.Documents with higher scores are
considered better than documents with lower scores.
Any non-negative integer can be used a score. By default, scores are set to 0.
Parameters
score | any non-negativeint representing the document's score. |
---|
Throws
IllegalArgumentException | if the score is negative. |
---|
public BuilderTypesetTtlMillis(long ttlMillis)
Sets the TTL (time-to-live) of theGenericDocument
,
in milliseconds.
The TTL is measured against
GenericDocument.getCreationTimestampMillis()
.At the timestamp of
creationTimestampMillis + ttlMillis
,measured in theSystem.currentTimeMillis()
time base, the document will be auto-deleted.
The default value is 0, which means the document is permanent and won't be
auto-deleted until the app is uninstalled or
AppSearchClient.remove(RemoveByDocumentIdRequest, String)
is called.
Parameters
ttlMillis | a non-negative duration in milliseconds. |
---|
Throws
IllegalArgumentException | if ttlMillis is negative. |
---|