SearchResult.MatchInfo
  public
  static
  final
  
  class
  SearchResult.MatchInfo
  
    extends Object
  
  
  
  
  
      implements
      
        Parcelable
      
  
  
| java.lang.Object | |
| ↳ | android.app.appsearch.SearchResult.MatchInfo | 
This class represents match objects for any snippets that might be present in SearchResults from a query.
 
A MatchInfo contains either a TextMatchInfo representing a text match
 snippet, or an EmbeddingMatchInfo representing an embedding match snippet.
Summary
Nested classes | |
|---|---|
        
        
        
        
        class | 
      
        SearchResult.MatchInfo.Builder
        Builder for   | 
    
Inherited constants | 
|---|
Fields | |
|---|---|
    public
    static
    final
    Creator<SearchResult.MatchInfo> | 
    
      CREATOR
      
  | 
  
Public methods | |
|---|---|
        
        
        
        
        
        SearchResult.EmbeddingMatchInfo
     | 
  
    
      
      getEmbeddingMatch()
      
      
        Retrieves the embedding-based match information.  | 
  
        
        
        
        
        
        CharSequence
     | 
  
    
      
      getExactMatch()
      
      
        Gets the exact term of the given entry that matched the query.  | 
  
        
        
        
        
        
        SearchResult.MatchRange
     | 
  
    
      
      getExactMatchRange()
      
      
        Gets the   | 
  
        
        
        
        
        
        String
     | 
  
    
      
      getFullText()
      
      
        Gets the full text corresponding to the given entry.  | 
  
        
        
        
        
        
        String
     | 
  
    
      
      getPropertyPath()
      
      
        Gets the property path corresponding to the given entry.  | 
  
        
        
        
        
        
        PropertyPath
     | 
  
    
      
      getPropertyPathObject()
      
      
        Gets a   | 
  
        
        
        
        
        
        CharSequence
     | 
  
    
      
      getSnippet()
      
      
        Gets the snippet corresponding to the given entry.  | 
  
        
        
        
        
        
        SearchResult.MatchRange
     | 
  
    
      
      getSnippetRange()
      
      
        Gets the snippet   | 
  
        
        
        
        
        
        CharSequence
     | 
  
    
      
      getSubmatch()
      
      
        Gets the exact term subsequence of the given entry that matched the query.  | 
  
        
        
        
        
        
        SearchResult.MatchRange
     | 
  
    
      
      getSubmatchRange()
      
      
        Gets the   | 
  
        
        
        
        
        
        SearchResult.TextMatchInfo
     | 
  
    
      
      getTextMatch()
      
      
        Retrieves the text-based match information.  | 
  
        
        
        
        
        
        void
     | 
  
    
      
      writeToParcel(Parcel dest, int flags)
      
      
        Flatten this object in to a Parcel.  | 
  
Inherited methods | |
|---|---|
Fields
CREATOR
public static final Creator<SearchResult.MatchInfo> CREATOR
Public methods
getEmbeddingMatch
public SearchResult.EmbeddingMatchInfo getEmbeddingMatch ()
Retrieves the embedding-based match information. Only populated when SearchSpec.shouldRetrieveEmbeddingMatchInfos() is true.
| Returns | |
|---|---|
SearchResult.EmbeddingMatchInfo | 
        A EmbeddingMatchInfo instance, or null if the match is not an embedding
     match. | 
      
getExactMatch
public CharSequence getExactMatch ()
Gets the exact term of the given entry that matched the query. Returns an empty CharSequence if the match is not text-based.
| Returns | |
|---|---|
CharSequence | 
        This value cannot be null. | 
      
getExactMatchRange
public SearchResult.MatchRange getExactMatchRange ()
Gets the MatchRange of the exact term of the given entry that matched the query.
 Returns [0, 0] if the match is not text-based.
| Returns | |
|---|---|
SearchResult.MatchRange | 
        This value cannot be null. | 
      
getFullText
public String getFullText ()
Gets the full text corresponding to the given entry. Returns an empty string if the match is not text-based.
| Returns | |
|---|---|
String | 
        This value cannot be null. | 
      
getPropertyPath
public String getPropertyPath ()
Gets the property path corresponding to the given entry.
A property path is a '.' - delimited sequence of property names indicating which property in the document these snippets correspond to.
Example properties: 'body', 'sender.name', 'sender.emailaddress', etc. For class example 1 this returns "subject"
| Returns | |
|---|---|
String | 
        This value cannot be null. | 
      
getPropertyPathObject
public PropertyPath getPropertyPathObject ()
Gets a PropertyPath object representing the property path corresponding to the
 given entry.
 
Methods such as GenericDocument.getPropertyDocument accept a path as a string
 rather than a PropertyPath object. However, you may want to manipulate the path
 before getting a property document. This method returns a PropertyPath rather
 than a String for easier path manipulation, which can then be converted to a String.
| Returns | |
|---|---|
PropertyPath | 
        This value cannot be null. | 
      
See also:
getSnippet
public CharSequence getSnippet ()
Gets the snippet corresponding to the given entry. Returns an empty CharSequence if the match is not text-based.
Snippet - Provides a subset of the content to display. Only populated when requested
 maxSnippetSize > 0. The size of this content can be changed by SearchSpec.Builder.setMaxSnippetSize(int). Windowing is centered around the middle of the
 matched token with content on either side clipped to token boundaries.
| Returns | |
|---|---|
CharSequence | 
        This value cannot be null. | 
      
getSnippetRange
public SearchResult.MatchRange getSnippetRange ()
Gets the snippet MatchRange corresponding to the given entry. Returns [0,0] if
 the match is not text-based.
 
Only populated when set maxSnippetSize > 0 in SearchSpec.Builder.setMaxSnippetSize(int).
| Returns | |
|---|---|
SearchResult.MatchRange | 
        This value cannot be null. | 
      
getSubmatch
public CharSequence getSubmatch ()
Gets the exact term subsequence of the given entry that matched the query. Returns an empty CharSequence if the match is not text-based.
| Returns | |
|---|---|
CharSequence | 
        This value cannot be null. | 
      
getSubmatchRange
public SearchResult.MatchRange getSubmatchRange ()
Gets the MatchRange of the submatch term subsequence of the given entry that
 matched the query. Returns [0, 0] if the match is not text-based.
| Returns | |
|---|---|
SearchResult.MatchRange | 
        This value cannot be null. | 
      
getTextMatch
public SearchResult.TextMatchInfo getTextMatch ()
Retrieves the text-based match information.
| Returns | |
|---|---|
SearchResult.TextMatchInfo | 
        A TextMatchInfo instance, or null if the match is not text-based. | 
      
writeToParcel
public void writeToParcel (Parcel dest, int flags)
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.PARCELABLE_WRITE_RETURN_VALUE.
 Value is either 0 or a combination of Parcelable.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.