SearchResult

public final class SearchResult extends Object
implements Parcelable

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.

See Also

Nested Class Summary

class SearchResult.Builder Builder for SearchResult objects. 
class SearchResult.MatchInfo This class represents match objects for any snippets that might be present in SearchResults from a query. 
class SearchResult.MatchRange Class providing the position range of matching information. 

Inherited Constant Summary

Field Summary

public static final Creator<SearchResult> CREATOR

Public Method Summary

String
getDatabaseName()
Contains the database name that stored the GenericDocument.
GenericDocument
getGenericDocument()
Contains the matching GenericDocument.
List<SearchResult>
getJoinedResults()
Gets a list of SearchResult joined from the join operation.
List<SearchResult.MatchInfo>
getMatchInfos()
Returns a list of SearchResult.MatchInfos providing information about how the document in getGenericDocument() matched the query.
String
getPackageName()
Contains the package name of the app that stored the GenericDocument.
double
getRankingSignal()
Returns the ranking signal of the GenericDocument, according to the ranking strategy set in SearchSpec.Builder.setRankingStrategy(int).
void
writeToParcel(Parcel dest, int flags)

Inherited Method Summary

Fields

public static final Creator<SearchResult> CREATOR

Public Methods

public String getDatabaseName ()

Contains the database name that stored the GenericDocument.

Returns
  • Name of the database within which the document is stored

public GenericDocument getGenericDocument ()

Contains the matching GenericDocument.

Returns
  • Document object which matched the query.

public List<SearchResult> getJoinedResults ()

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 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.

Returns
  • a List of SearchResults containing joined documents.

public List<SearchResult.MatchInfo> getMatchInfos ()

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

Returns

public String getPackageName ()

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

Returns
  • Package name that stored the document

public double getRankingSignal ()

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:

Returns
  • Ranking signal of the document

public void writeToParcel (Parcel dest, int flags)