Added in API level 31

SearchResult

class SearchResult : Parcelable
kotlin.Any
   ↳ android.app.appsearch.SearchResult

This class represents one of the results obtained from an AppSearch query.

This allows clients to obtain:

  • The document which matched, using getGenericDocument
  • Information about which properties in the document matched, and "snippet" information containing textual summaries of the document's matches, using getMatchInfos

"Snippet" refers to a substring of text from the content of document that is returned as a part of search result.

Summary

Nested classes

Builder for SearchResult objects.

This class represents match objects for any snippets that might be present in SearchResults from a query.

Class providing the position range of matching information.

Inherited constants
Public methods
String

Contains the database name that stored the GenericDocument.

GenericDocument

Contains the matching GenericDocument.

MutableList<SearchResult!>

Gets a list of SearchResult joined from the join operation.

MutableList<SearchResult.MatchInfo!>

Returns a list of MatchInfos providing information about how the document in getGenericDocument matched the query.

String

Contains the package name of the app that stored the GenericDocument.

Double

Returns the ranking signal of the GenericDocument, according to the ranking strategy set in SearchSpec.Builder#setRankingStrategy(int).

Unit
writeToParcel(dest: Parcel, flags: Int)

Flatten this object in to a Parcel.

Properties
static Parcelable.Creator<SearchResult!>

Public methods

getDatabaseName

Added in API level 31
fun getDatabaseName(): String

Contains the database name that stored the GenericDocument.

Return
String Name of the database within which the document is stored This value cannot be null.

getGenericDocument

Added in API level 31
fun getGenericDocument(): GenericDocument

Contains the matching GenericDocument.

Return
GenericDocument Document object which matched the query. This value cannot be null.

getJoinedResults

Added in API level 34
fun getJoinedResults(): MutableList<SearchResult!>

Gets a list of SearchResult joined from the join operation.

These joined documents match the outer document as specified in the JoinSpec with parentPropertyExpression and childPropertyExpression. They are ordered according to the JoinSpec#getNestedSearchSpec, and as many SearchResults as specified by android.app.appsearch.JoinSpec#getMaxJoinedResultCount will be returned. If no JoinSpec was specified, this returns an empty list.

This method is inefficient to call repeatedly, as new SearchResult objects are created each time.

Return
MutableList<SearchResult!> a List of SearchResults containing joined documents. This value cannot be null.

getMatchInfos

Added in API level 31
fun getMatchInfos(): MutableList<SearchResult.MatchInfo!>

Returns a list of MatchInfos providing information about how the document in getGenericDocument matched the query.

Return
MutableList<SearchResult.MatchInfo!> List of matches based on SearchSpec. If snippeting is disabled using android.app.appsearch.SearchSpec.Builder#setSnippetCount or android.app.appsearch.SearchSpec.Builder#setSnippetCountPerProperty, for all results after that value, this method returns an empty list. This value cannot be null.

getPackageName

Added in API level 31
fun getPackageName(): String

Contains the package name of the app that stored the GenericDocument.

Return
String Package name that stored the document This value cannot be null.

getRankingSignal

Added in API level 31
fun getRankingSignal(): Double

Returns the ranking signal of the GenericDocument, according to the ranking strategy set in SearchSpec.Builder#setRankingStrategy(int).

The meaning of the ranking signal and its value is determined by the selected ranking strategy:

Return
Double Ranking signal of the document

writeToParcel

fun writeToParcel(
    dest: Parcel,
    flags: Int
): Unit

Flatten this object in to a Parcel.

Parameters
dest Parcel: This value cannot be null.
flags Int: Additional flags about how the object should be written. May be 0 or PARCELABLE_WRITE_RETURN_VALUE. Value is either 0 or a combination of android.os.Parcelable#PARCELABLE_WRITE_RETURN_VALUE, and android.os.Parcelable.PARCELABLE_ELIDE_DUPLICATES

Properties

CREATOR

static val CREATOR: Parcelable.Creator<SearchResult!>