ImpressionAction


@RequiresFeature(enforcement = "androidx.appsearch.app.Features#isFeatureSupported", name = Features.JOIN_SPEC_AND_QUALIFIED_ID)
@Document(name = "builtin:ImpressionAction")
@ExperimentalAppSearchApi
class ImpressionAction : TakenAction


ImpressionAction is a built-in AppSearch document type that contains different metrics. Clients can report the user's impression actions on a androidx.appsearch.app.SearchResult document.

In order to use this document type, the client must explicitly set this schema type via addDocumentClasses.

Impression actions can be used as signals to boost ranking via androidx.appsearch.app.JoinSpec API in future search requests.

Since ImpressionAction is an AppSearch document, the client can handle deletion via removeAsync or document time-to-live (TTL). The default TTL is 60 days.

Summary

Public functions

String?

Returns the user-entered search input (without any operators or rewriting) that yielded the androidx.appsearch.app.SearchResult which impressed the user.

String?

Returns the qualified id of the androidx.appsearch.app.SearchResult document that impressed the user.

Int

Returns the global rank of the androidx.appsearch.app.SearchResult document.

Int

Returns the rank of the androidx.appsearch.app.SearchResult document among the user-defined block.

Inherited functions

From androidx.appsearch.usagereporting.TakenAction
Long

Returns the timestamp when the user took the action, in milliseconds since Unix epoch.

Long

Returns the time-to-live (TTL) of the TakenAction document as a duration in milliseconds.

String

Returns the unique identifier of the TakenAction.

String

Returns the namespace of the TakenAction.

Public functions

getQuery

Added in 1.1.0-alpha07
fun getQuery(): String?

Returns the user-entered search input (without any operators or rewriting) that yielded the androidx.appsearch.app.SearchResult which impressed the user.

getReferencedQualifiedId

Added in 1.1.0-alpha07
fun getReferencedQualifiedId(): String?

Returns the qualified id of the androidx.appsearch.app.SearchResult document that impressed the user.

A qualified id is a string generated by package, database, namespace, and document id. See createQualifiedId for more details.

getResultRankGlobal

Added in 1.1.0-alpha07
fun getResultRankGlobal(): Int

Returns the global rank of the androidx.appsearch.app.SearchResult document.

Global rank reflects the order of androidx.appsearch.app.SearchResult documents returned by AppSearch.

For example, AppSearch returns 2 pages with 10 androidx.appsearch.app.SearchResult documents for each page. Then the global ranks of them will be 1 to 10 for the first page, and 11 to 20 for the second page.

If unset, then the global rank of the androidx.appsearch.app.SearchResult document will be set to -1 to mark invalid.

getResultRankInBlock

Added in 1.1.0-alpha07
fun getResultRankInBlock(): Int

Returns the rank of the androidx.appsearch.app.SearchResult document among the user-defined block.

The client can define its own custom definition for block, e.g. corpus name, group, etc.

For example, a client defines the block as corpus, and AppSearch returns 5 documents with corpus = ["corpus1", "corpus1", "corpus2", "corpus3", "corpus2"]. Then the block ranks of them = [1, 2, 1, 1, 2].

If the client is not presenting the results in multiple blocks, they should set this value to match getResultRankGlobal.

If unset, then the block rank of the androidx.appsearch.app.SearchResult document will be set to -1 to mark invalid.