SearchResult
  public
  
  final
  
  class
  SearchResult
  
    extends Object
  
  
  
  
  
      implements
      
        Parcelable
      
  
  
| java.lang.Object | |
| ↳ | 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.
See also:
Summary
| Nested classes | |
|---|---|
| 
        
        
        
        
        class | SearchResult.BuilderBuilder for  | 
| 
        
        
        
        
        class | SearchResult.EmbeddingMatchInfoThis class represents match objects for any snippets that might be present in  | 
| 
        
        
        
        
        class | SearchResult.MatchInfoThis class represents match objects for any snippets that might be present in  | 
| 
        
        
        
        
        class | SearchResult.MatchRangeClass providing the position range of a text match information. | 
| 
        
        
        
        
        class | SearchResult.TextMatchInfoThis class represents match objects for any text match snippets that might be present in
  | 
| Inherited constants | 
|---|
| Fields | |
|---|---|
| 
    public
    static
    final
    Creator<SearchResult> | CREATOR
 | 
| Public methods | |
|---|---|
| 
        
        
        
        
        
        String | 
      getDatabaseName()
      Contains the database name that stored the  | 
| 
        
        
        
        
        
        GenericDocument | 
      getGenericDocument()
      Contains the matching  | 
| 
        
        
        
        
        
        List<Double> | 
      getInformationalRankingSignals()
      Returns the informational ranking signals of the  | 
| 
        
        
        
        
        
        List<SearchResult> | 
      getJoinedResults()
      Gets a list of  | 
| 
        
        
        
        
        
        List<SearchResult.MatchInfo> | 
      getMatchInfos()
      Returns a list of  | 
| 
        
        
        
        
        
        String | 
      getPackageName()
      Contains the package name of the app that stored the  | 
| 
        
        
        
        
        
        Map<String, List<String>> | 
      getParentTypeMap()
      Returns the map from schema type names to the list of their parent types. | 
| 
        
        
        
        
        
        double | 
      getRankingSignal()
      Returns the ranking signal of the  | 
| 
        
        
        
        
        
        void | 
      writeToParcel(Parcel dest, int flags)
      Flatten this object in to a Parcel. | 
| Inherited methods | |
|---|---|
Fields
CREATOR
public static final Creator<SearchResult> CREATOR
Public methods
getDatabaseName
public String getDatabaseName ()
Contains the database name that stored the GenericDocument.
| Returns | |
|---|---|
| String | Name of the database within which the document is stored
 This value cannot be null. | 
getGenericDocument
public GenericDocument getGenericDocument ()
Contains the matching GenericDocument.
| Returns | |
|---|---|
| GenericDocument | Document object which matched the query.
 This value cannot be null. | 
getInformationalRankingSignals
public List<Double> getInformationalRankingSignals ()
Returns the informational ranking signals of the GenericDocument, according to the
 expressions added in SearchSpec.Builder.addInformationalRankingExpressions.
| Returns | |
|---|---|
| List<Double> | This value cannot be null. | 
getJoinedResults
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 | |
|---|---|
| List<SearchResult> | a List of SearchResults containing joined documents.
 This value cannot be null. | 
getMatchInfos
public List<SearchResult.MatchInfo> getMatchInfos ()
Returns a list of MatchInfos providing information about how the document in getGenericDocument() matched the query.
| Returns | |
|---|---|
| List<SearchResult.MatchInfo> | List of matches based on SearchSpec. If snippeting is disabled usingSearchSpec.Builder.setSnippetCount(int)orSearchSpec.Builder.setSnippetCountPerProperty(int), for all results after that value, this
     method returns an empty list.
 This value cannot benull. | 
getPackageName
public String getPackageName ()
Contains the package name of the app that stored the GenericDocument.
| Returns | |
|---|---|
| String | Package name that stored the document
 This value cannot be null. | 
getParentTypeMap
public Map<String, List<String>> getParentTypeMap ()
Returns the map from schema type names to the list of their parent types.
The map includes entries for the GenericDocument's own type and all of the nested
 documents' types. Child types are guaranteed to appear before parent types in each list.
 
Parent types include transitive parents.
Calling this function repeatedly is inefficient. Prefer to retain the Map returned by this function, rather than calling it multiple times.
| Returns | |
|---|---|
| Map<String, List<String>> | This value cannot be null. | 
getRankingSignal
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:
- SearchSpec.RANKING_STRATEGY_NONE- this value will be 0
- SearchSpec.RANKING_STRATEGY_DOCUMENT_SCORE- the value returned by calling- GenericDocument.getScore()on the document returned by- getGenericDocument()
- SearchSpec.RANKING_STRATEGY_CREATION_TIMESTAMP- the value returned by calling- GenericDocument.getCreationTimestampMillis()on the document returned by- getGenericDocument()
- SearchSpec.RANKING_STRATEGY_RELEVANCE_SCORE- an arbitrary double value where a higher value means more relevant
- SearchSpec.RANKING_STRATEGY_USAGE_COUNT- the number of times usage has been reported for the document returned by- getGenericDocument()
- SearchSpec.RANKING_STRATEGY_USAGE_LAST_USED_TIMESTAMP- the timestamp of the most recent usage that has been reported for the document returned by- getGenericDocument()
| Returns | |
|---|---|
| double | Ranking signal of the document | 
writeToParcel
public void writeToParcel (Parcel dest, int flags)
Flatten this object in to a Parcel.
| Parameters | |
|---|---|
| dest | Parcel: This value cannot benull. | 
| flags | int: Additional flags about how the object should be written.
 May be 0 orParcelable.PARCELABLE_WRITE_RETURN_VALUE.
 Value is either0or a combination ofParcelable.PARCELABLE_WRITE_RETURN_VALUE, and android.os.Parcelable.PARCELABLE_ELIDE_DUPLICATES | 
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2025-09-17 UTC.
