PutDocumentsRequest.Builder


public final class PutDocumentsRequest.Builder


Builder for PutDocumentsRequest objects.

Summary

Public constructors

Public methods

@NonNull PutDocumentsRequest.Builder
addDocuments(@NonNull Object[] documents)

Adds one or more annotated androidx.appsearch.annotation.Document documents to the request.

@NonNull PutDocumentsRequest.Builder

Adds a collection of annotated androidx.appsearch.annotation.Document documents to the request.

@NonNull PutDocumentsRequest.Builder
addGenericDocuments(@NonNull GenericDocument[] documents)

Adds one or more GenericDocument objects to the request.

@NonNull PutDocumentsRequest.Builder

Adds a collection of GenericDocument objects to the request.

@NonNull PutDocumentsRequest.Builder
addTakenActions(@NonNull TakenAction[] takenActions)

Adds one or more TakenAction objects to the request.

@NonNull PutDocumentsRequest.Builder

Adds a collection of TakenAction objects to the request.

@NonNull PutDocumentsRequest

Creates a new PutDocumentsRequest object.

Public constructors

Builder

Added in 1.1.0-alpha06
public Builder()

Public methods

addDocuments

public @NonNull PutDocumentsRequest.Builder addDocuments(@NonNull Object[] documents)

Adds one or more annotated androidx.appsearch.annotation.Document documents to the request.

Parameters
@NonNull Object[] documents

annotated androidx.appsearch.annotation.Document documents.

Throws
androidx.appsearch.exceptions.AppSearchException

if an error occurs converting a document class into a GenericDocument.

addDocuments

Added in 1.1.0-alpha06
public @NonNull PutDocumentsRequest.Builder addDocuments(@NonNull Collection<Object> documents)

Adds a collection of annotated androidx.appsearch.annotation.Document documents to the request.

Parameters
@NonNull Collection<Object> documents

annotated androidx.appsearch.annotation.Document documents.

Throws
androidx.appsearch.exceptions.AppSearchException

if an error occurs converting a document into a GenericDocument.

addGenericDocuments

public @NonNull PutDocumentsRequest.Builder addGenericDocuments(@NonNull GenericDocument[] documents)

Adds one or more GenericDocument objects to the request.

addGenericDocuments

Added in 1.1.0-alpha06
public @NonNull PutDocumentsRequest.Builder addGenericDocuments(@NonNull Collection<GenericDocument> documents)

Adds a collection of GenericDocument objects to the request.

addTakenActions

public @NonNull PutDocumentsRequest.Builder addTakenActions(@NonNull TakenAction[] takenActions)

Adds one or more TakenAction objects to the request.

Clients can construct TakenAction documents to report the user's actions on search results, and these actions can be used as signals to boost result ranking in future search requests. See TakenAction for more details.

Clients should report search and click actions together sorted by getActionTimestampMillis in chronological order.

For example, if there are 2 search actions, with 1 click action associated with the first and 2 click actions associated with the second, then clients should report [searchAction1, clickAction1, searchAction2, clickAction2, clickAction3].

Certain anonymized information about actions reported using this API may be uploaded using statsd and may be used to improve the quality of the search algorithms. Most of the information in this class is already non-identifiable, such as durations and its position in the result set. Identifiable information which you choose to provide, such as the query string, will be anonymized using techniques like Federated Analytics to ensure only the most frequently searched terms across the whole user population are retained and available for study.

You can alternatively use the addDocuments API with TakenAction document to retain the benefits of joining and using it on-device, without triggering any of the anonymized stats uploading described above.

Parameters
@NonNull TakenAction[] takenActions

one or more TakenAction objects.

addTakenActions

Added in 1.1.0-alpha06
public @NonNull PutDocumentsRequest.Builder addTakenActions(@NonNull Collection<TakenAction> takenActions)

Adds a collection of TakenAction objects to the request.

Parameters
@NonNull Collection<TakenAction> takenActions

a collection of TakenAction objects.

See also
addTakenActions

build

Added in 1.1.0-alpha06
public @NonNull PutDocumentsRequest build()

Creates a new PutDocumentsRequest object.

Throws
java.lang.IllegalArgumentException

if there is any id collision between normal and action documents.