The builder class for GenericDocument
.
Public Constructor Summary
* | |
* |
Public Method Summary
GenericDocument | |
BuilderType | |
BuilderType | setCreationTimestampMillis
(long creationTimestampMillis)
|
BuilderType | |
BuilderType | setNamespace
( String
namespace)
Sets the app-defined namespace this document resides in, changing the value
provided in the constructor.
|
BuilderType | setPropertyBoolean
( String
name,
boolean... values)
Sets one or multiple
boolean
values for a property, replacing its
previous values. |
BuilderType | setPropertyBytes
( String
name,
byte... values)
Sets one or multiple
byte[]
for a property, replacing its previous
values. |
BuilderType | |
BuilderType | setPropertyDouble
( String
name,
double... values)
Sets one or multiple
double
values for a property, replacing its
previous values. |
BuilderType | setPropertyLong
( String
name,
long... values)
Sets one or multiple
long
values for a property, replacing its
previous values. |
BuilderType | setPropertyString
( String
name, String...
values)
Sets one or multiple
String
values for a property, replacing its
previous values. |
BuilderType | setSchemaType
( String
schemaType)
Sets the schema type of this document, changing the value provided in the
constructor.
|
BuilderType | |
BuilderType |
Inherited Method Summary
Public Constructors
public Builder ( String namespace, String id, String schemaType)
Creates a new GenericDocument.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 the GenericDocument
. |
---|---|
id | the unique identifier for the GenericDocument
in its namespace. |
schemaType | the AppSearchSchema
type of the GenericDocument
.
The provided schemaType
must be defined using AppSearchClient.setSchema(SetSchemaRequest, String)
prior to inserting a
document of this schemaType
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
. |
public Builder ( GenericDocument document)
Creates a new GenericDocument.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
public GenericDocument build ()
Builds the GenericDocument
object.
public BuilderType clearProperty ( String name)
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
public BuilderType setCreationTimestampMillis (long creationTimestampMillis)
Sets the creation timestamp of the GenericDocument
,
in milliseconds.
This should be set using a value obtained from the System.currentTimeMillis()
time base.
If this method is not called, this will be set to the time the object is built.
Parameters
public BuilderType setId ( String id)
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 BuilderType setNamespace ( String namespace)
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 BuilderType setPropertyBoolean ( String name, boolean... values)
Sets one or multiple boolean
values for a property, replacing its
previous values.
Parameters
name | the name associated with the values
. Must match the name for this
property as given in AppSearchSchema.PropertyConfig.getName()
. |
---|---|
values | the boolean
values of the property. |
Throws
null
.public BuilderType setPropertyBytes ( String name, byte... values)
Sets one or multiple byte[]
for a property, replacing its previous
values.
Parameters
name | the name associated with the values
. Must match the name for this
property as given in AppSearchSchema.PropertyConfig.getName()
. |
---|---|
values | the byte[]
of the property. |
Throws
byte[]
is null
, or if name is empty.public BuilderType setPropertyDocument ( String name, GenericDocument... values)
Sets one or multiple GenericDocument
values for a property, replacing its previous values.
Parameters
name | the name associated with the values
. Must match the name for this
property as given in AppSearchSchema.PropertyConfig.getName()
. |
---|---|
values | the GenericDocument
values of the property. |
Throws
public BuilderType setPropertyDouble ( String name, double... values)
Sets one or multiple double
values for a property, replacing its
previous values.
Parameters
name | the name associated with the values
. Must match the name for this
property as given in AppSearchSchema.PropertyConfig.getName()
. |
---|---|
values | the double
values of the property. |
Throws
null
.public BuilderType setPropertyLong ( String name, long... values)
Sets one or multiple long
values for a property, replacing its previous
values.
Parameters
name | the name associated with the values
. Must match the name for this
property as given in AppSearchSchema.PropertyConfig.getName()
. |
---|---|
values | the long
values of the property. |
Throws
null
.public BuilderType setPropertyString ( String name, String... values)
Sets one or multiple String
values for a property, replacing its
previous values.
Parameters
name | the name associated with the values
. Must match the name for this
property as given in AppSearchSchema.PropertyConfig.getName()
. |
---|---|
values | the String
values of the property. |
Throws
String
is null
or "".public BuilderType setSchemaType ( 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 BuilderType setScore (int score)
Sets the score of the GenericDocument
.
The score is a query-independent measure of the document's quality, relative to
other GenericDocument
objects of the same AppSearchSchema
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
int
representing the document's score.Throws
public BuilderType setTtlMillis (long ttlMillis)
Sets the TTL (time-to-live) of the GenericDocument
,
in milliseconds.
The TTL is measured against GenericDocument.getCreationTimestampMillis()
. At the timestamp of creationTimestampMillis + ttlMillis
, measured in the System.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.