Added in [version 36.1](https://developer.android.com/topic/libraries/support-library/revisions)  
Also in [T Extensions 18](https://developer.android.com/sdkExtensions) Summary: [Inherited Constants](https://developer.android.com/reference/android/app/appsearch/SearchResult.TextMatchInfo#inhconstants) \| [Fields](https://developer.android.com/reference/android/app/appsearch/SearchResult.TextMatchInfo#lfields) \| [Ctors](https://developer.android.com/reference/android/app/appsearch/SearchResult.TextMatchInfo#pubctors) \| [Methods](https://developer.android.com/reference/android/app/appsearch/SearchResult.TextMatchInfo#pubmethods) \| [Inherited Methods](https://developer.android.com/reference/android/app/appsearch/SearchResult.TextMatchInfo#inhmethods)

# SearchResult.TextMatchInfo

*** ** * ** ***

[Kotlin](https://developer.android.com/reference/kotlin/android/app/appsearch/SearchResult.TextMatchInfo "View this page in Kotlin") \|Java


`
public
static
final

class
SearchResult.TextMatchInfo
`


`

extends https://developer.android.com/reference/java/lang/Object


`

`


implements

https://developer.android.com/reference/android/os/Parcelable


`

|---|---|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object) ||
| ↳ | android.app.appsearch.SearchResult.TextMatchInfo |

<br />

*** ** * ** ***

This class represents match objects for any text match snippets that might be present in
`https://developer.android.com/reference/android/app/appsearch/SearchResults` from a string query. Using this class, you can get:

- the full text - all of the text in that String property
- the exact term match - the 'term' (full word) that matched the query
- the subterm match - the portion of the matched term that appears in the query
- a suggested text snippet - a portion of the full text surrounding the exact term match, set to term boundaries. The size of the snippet is specified in `https://developer.android.com/reference/android/app/appsearch/SearchSpec.Builder#setMaxSnippetSize(int)`

for each text match in the document.

Class Example 1:

A document contains the following text in property "subject":

"A commonly used fake word is foo. Another nonsense word that\\u2019s used a lot is bar."

If the queryExpression is "foo" and `https://developer.android.com/reference/android/app/appsearch/SearchSpec#getMaxSnippetSize()` is 10,

- `https://developer.android.com/reference/android/app/appsearch/SearchResult.TextMatchInfo#getFullText()` returns "A commonly used fake word is foo. Another nonsense word that\\u2019s used a lot is bar."
- `https://developer.android.com/reference/android/app/appsearch/SearchResult.TextMatchInfo#getExactMatchRange()` returns \[29, 32\]
- `https://developer.android.com/reference/android/app/appsearch/SearchResult.TextMatchInfo#getExactMatch()` returns "foo"
- `https://developer.android.com/reference/android/app/appsearch/SearchResult.TextMatchInfo#getSubmatchRange()` returns \[29, 32\]
- `https://developer.android.com/reference/android/app/appsearch/SearchResult.TextMatchInfo#getSubmatch()` returns "foo"
- `https://developer.android.com/reference/android/app/appsearch/SearchResult.TextMatchInfo#getSnippetRange()` returns \[26, 33\]
- `https://developer.android.com/reference/android/app/appsearch/SearchResult.TextMatchInfo#getSnippet()` returns "is foo."


Class Example 2:

A document contains one property named "subject" and one property named "sender" which
contains a "name" property.

In this case, we will have 2 property paths: `sender.name` and `subject`.

Let `sender.name = "Test Name Jr."` and `subject = "Testing 1 2 3"`

If the queryExpression is "Test" with `https://developer.android.com/reference/android/app/appsearch/SearchSpec#TERM_MATCH_PREFIX` and `https://developer.android.com/reference/android/app/appsearch/SearchSpec#getMaxSnippetSize()` is 10. We will have 2 matches:

Match-1

- `https://developer.android.com/reference/android/app/appsearch/SearchResult.TextMatchInfo#getFullText()` returns "Test Name Jr."
- `https://developer.android.com/reference/android/app/appsearch/SearchResult.TextMatchInfo#getExactMatchRange()` returns \[0, 4\]
- `https://developer.android.com/reference/android/app/appsearch/SearchResult.TextMatchInfo#getExactMatch()` returns "Test"
- `https://developer.android.com/reference/android/app/appsearch/SearchResult.TextMatchInfo#getSubmatchRange()` returns \[0, 4\]
- `https://developer.android.com/reference/android/app/appsearch/SearchResult.TextMatchInfo#getSubmatch()` returns "Test"
- `https://developer.android.com/reference/android/app/appsearch/SearchResult.TextMatchInfo#getSnippetRange()` returns \[0, 9\]
- `https://developer.android.com/reference/android/app/appsearch/SearchResult.TextMatchInfo#getSnippet()` returns "Test Name"

Match-2

- `https://developer.android.com/reference/android/app/appsearch/SearchResult.TextMatchInfo#getFullText()` returns "Testing 1 2 3"
- `https://developer.android.com/reference/android/app/appsearch/SearchResult.TextMatchInfo#getExactMatchRange()` returns \[0, 7\]
- `https://developer.android.com/reference/android/app/appsearch/SearchResult.TextMatchInfo#getExactMatch()` returns "Testing"
- `https://developer.android.com/reference/android/app/appsearch/SearchResult.TextMatchInfo#getSubmatchRange()` returns \[0, 4\]
- `https://developer.android.com/reference/android/app/appsearch/SearchResult.TextMatchInfo#getSubmatch()` returns "Test"
- `https://developer.android.com/reference/android/app/appsearch/SearchResult.TextMatchInfo#getSnippetRange()` returns \[0, 9\]
- `https://developer.android.com/reference/android/app/appsearch/SearchResult.TextMatchInfo#getSnippet()` returns "Testing 1"

<br />

## Summary

| ### Inherited constants |
|---|
| From interface `https://developer.android.com/reference/android/os/Parcelable` |---|---| | `int` | `https://developer.android.com/reference/android/os/Parcelable#CONTENTS_FILE_DESCRIPTOR` Descriptor bit used with `https://developer.android.com/reference/android/os/Parcelable#describeContents()`: indicates that the Parcelable object's flattened representation includes a file descriptor. | | `int` | `https://developer.android.com/reference/android/os/Parcelable#PARCELABLE_WRITE_RETURN_VALUE` Flag for use with `https://developer.android.com/reference/android/os/Parcelable#writeToParcel(android.os.Parcel,%20int)`: the object being written is a return value, that is the result of a function such as "`Parcelable someFunction()`", "`void someFunction(out Parcelable)`", or "`void someFunction(inout Parcelable)`". | |

| ### Fields ||
|---|---|
| ` public static final https://developer.android.com/reference/android/os/Parcelable.Creator<https://developer.android.com/reference/android/app/appsearch/SearchResult.TextMatchInfo>` | `https://developer.android.com/reference/android/app/appsearch/SearchResult.TextMatchInfo#CREATOR` |

| ### Public constructors ||
|---|---|
| ` https://developer.android.com/reference/android/app/appsearch/SearchResult.TextMatchInfo#TextMatchInfo(android.app.appsearch.SearchResult.MatchRange,%20android.app.appsearch.SearchResult.MatchRange,%20android.app.appsearch.SearchResult.MatchRange)(https://developer.android.com/reference/android/app/appsearch/SearchResult.MatchRange exactMatchRange, https://developer.android.com/reference/android/app/appsearch/SearchResult.MatchRange submatchRange, https://developer.android.com/reference/android/app/appsearch/SearchResult.MatchRange snippetRange) ` Creates a new immutable TextMatchInfo. |

| ### Public methods ||
|---|---|
| ` int` | ` https://developer.android.com/reference/android/app/appsearch/SearchResult.TextMatchInfo#describeContents()() ` Describe the kinds of special objects contained in this Parcelable instance's marshaled representation. |
| ` https://developer.android.com/reference/java/lang/CharSequence` | ` https://developer.android.com/reference/android/app/appsearch/SearchResult.TextMatchInfo#getExactMatch()() ` Gets the exact term of the given entry that matched the query. |
| ` https://developer.android.com/reference/android/app/appsearch/SearchResult.MatchRange` | ` https://developer.android.com/reference/android/app/appsearch/SearchResult.TextMatchInfo#getExactMatchRange()() ` Gets the `https://developer.android.com/reference/android/app/appsearch/SearchResult.MatchRange` of the exact term of the given entry that matched the query. |
| ` https://developer.android.com/reference/java/lang/String` | ` https://developer.android.com/reference/android/app/appsearch/SearchResult.TextMatchInfo#getFullText()() ` Gets the full text corresponding to the given entry. |
| ` https://developer.android.com/reference/java/lang/CharSequence` | ` https://developer.android.com/reference/android/app/appsearch/SearchResult.TextMatchInfo#getSnippet()() ` Gets the snippet corresponding to the given entry. |
| ` https://developer.android.com/reference/android/app/appsearch/SearchResult.MatchRange` | ` https://developer.android.com/reference/android/app/appsearch/SearchResult.TextMatchInfo#getSnippetRange()() ` Gets the snippet `https://developer.android.com/reference/android/app/appsearch/SearchResult.TextMatchInfo` corresponding to the given entry. |
| ` https://developer.android.com/reference/java/lang/CharSequence` | ` https://developer.android.com/reference/android/app/appsearch/SearchResult.TextMatchInfo#getSubmatch()() ` Gets the exact term subsequence of the given entry that matched the query. |
| ` https://developer.android.com/reference/android/app/appsearch/SearchResult.MatchRange` | ` https://developer.android.com/reference/android/app/appsearch/SearchResult.TextMatchInfo#getSubmatchRange()() ` Gets the `https://developer.android.com/reference/android/app/appsearch/SearchResult.MatchRange` of the exact term subsequence of the given entry that matched the query. |
| ` void` | ` https://developer.android.com/reference/android/app/appsearch/SearchResult.TextMatchInfo#writeToParcel(android.os.Parcel,%20int)(https://developer.android.com/reference/android/os/Parcel dest, int flags) ` Flatten this object in to a Parcel. |

| ### Inherited methods |
|---|---|
| From class ` https://developer.android.com/reference/java/lang/Object ` |---|---| | ` https://developer.android.com/reference/java/lang/Object` | ` https://developer.android.com/reference/java/lang/Object#clone()() ` Creates and returns a copy of this object. | | ` boolean` | ` https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object)(https://developer.android.com/reference/java/lang/Object obj) ` Indicates whether some other object is "equal to" this one. | | ` void` | ` https://developer.android.com/reference/java/lang/Object#finalize()() ` Called by the garbage collector on an object when garbage collection determines that there are no more references to the object. | | ` final https://developer.android.com/reference/java/lang/Class<?>` | ` https://developer.android.com/reference/java/lang/Object#getClass()() ` Returns the runtime class of this `Object`. | | ` int` | ` https://developer.android.com/reference/java/lang/Object#hashCode()() ` Returns a hash code value for the object. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#notify()() ` Wakes up a single thread that is waiting on this object's monitor. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#notifyAll()() ` Wakes up all threads that are waiting on this object's monitor. | | ` https://developer.android.com/reference/java/lang/String` | ` https://developer.android.com/reference/java/lang/Object#toString()() ` Returns a string representation of the object. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#wait(long,%20int)(long timeoutMillis, int nanos) ` Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#wait(long)(long timeoutMillis) ` Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#wait()() ` Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*. | ||
| From interface ` https://developer.android.com/reference/android/os/Parcelable ` |---|---| | ` abstract int` | ` https://developer.android.com/reference/android/os/Parcelable#describeContents()() ` Describe the kinds of special objects contained in this Parcelable instance's marshaled representation. | | ` abstract void` | ` https://developer.android.com/reference/android/os/Parcelable#writeToParcel(android.os.Parcel,%20int)(https://developer.android.com/reference/android/os/Parcel dest, int flags) ` Flatten this object in to a Parcel. | ||

## Fields

### CREATOR

Added in [version 36.1](https://developer.android.com/topic/libraries/support-library/revisions)  
Also in [T Extensions 18](https://developer.android.com/sdkExtensions)

```
public static final Creator<SearchResult.TextMatchInfo> CREATOR
```

<br />

<br />

## Public constructors

### TextMatchInfo

Added in [version 36.1](https://developer.android.com/topic/libraries/support-library/revisions)  
Also in [T Extensions 18](https://developer.android.com/sdkExtensions)

```
public TextMatchInfo (SearchResult.MatchRange exactMatchRange, 
                SearchResult.MatchRange submatchRange, 
                SearchResult.MatchRange snippetRange)
```

Creates a new immutable TextMatchInfo.

<br />

| Parameters ||
|---|---|
| `exactMatchRange` | `SearchResult.MatchRange`: the exact `https://developer.android.com/reference/android/app/appsearch/SearchResult.MatchRange` for the entry. This value cannot be `null`. <br /> |
| `submatchRange` | `SearchResult.MatchRange`: the sub-match `https://developer.android.com/reference/android/app/appsearch/SearchResult.MatchRange` for the entry. This value cannot be `null`. <br /> |
| `snippetRange` | `SearchResult.MatchRange`: the snippet `https://developer.android.com/reference/android/app/appsearch/SearchResult.MatchRange` for the entry. This value cannot be `null`. <br /> |

## Public methods

### describeContents

Added in [version 36.1](https://developer.android.com/topic/libraries/support-library/revisions)

```
public int describeContents ()
```

Describe the kinds of special objects contained in this Parcelable
instance's marshaled representation. For example, if the object will
include a file descriptor in the output of `https://developer.android.com/reference/android/os/Parcelable#writeToParcel(android.os.Parcel,%20int)`,
the return value of this method must include the
`https://developer.android.com/reference/android/os/Parcelable#CONTENTS_FILE_DESCRIPTOR` bit.

<br />

| Returns ||
|---|---|
| `int` | a bitmask indicating the set of special object types marshaled by this Parcelable object instance. Value is either `0` or - `https://developer.android.com/reference/android/os/Parcelable#CONTENTS_FILE_DESCRIPTOR` |

### getExactMatch

Added in [version 36.1](https://developer.android.com/topic/libraries/support-library/revisions)  
Also in [T Extensions 18](https://developer.android.com/sdkExtensions)

```
public CharSequence getExactMatch ()
```

Gets the exact term of the given entry that matched the query.

Class example 1: this returns "foo".

Class example 2: for the first `https://developer.android.com/reference/android/app/appsearch/SearchResult.TextMatchInfo`, this returns "Test" and, for the
second `https://developer.android.com/reference/android/app/appsearch/SearchResult.TextMatchInfo`, this returns "Testing".

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/CharSequence` | This value cannot be `null`. <br /> |

### getExactMatchRange

Added in [version 36.1](https://developer.android.com/topic/libraries/support-library/revisions)  
Also in [T Extensions 18](https://developer.android.com/sdkExtensions)

```
public SearchResult.MatchRange getExactMatchRange ()
```

Gets the `https://developer.android.com/reference/android/app/appsearch/SearchResult.MatchRange` of the exact term of the given entry that matched the query.

Class example 1: this returns \[29, 32\].

Class example 2: for the first `https://developer.android.com/reference/android/app/appsearch/SearchResult.TextMatchInfo`, this returns \[0, 4\] and, for the
second `https://developer.android.com/reference/android/app/appsearch/SearchResult.TextMatchInfo`, this returns \[0, 7\].

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/app/appsearch/SearchResult.MatchRange` | This value cannot be `null`. <br /> |

### getFullText

Added in [version 36.1](https://developer.android.com/topic/libraries/support-library/revisions)  
Also in [T Extensions 18](https://developer.android.com/sdkExtensions)

```
public String getFullText ()
```

Gets the full text corresponding to the given entry.

Class example 1: this returns "A commonly used fake word is foo. Another nonsense word
that's used a lot is bar."

Class example 2: for the first `https://developer.android.com/reference/android/app/appsearch/SearchResult.TextMatchInfo`, this returns "Test Name Jr."
and, for the second `https://developer.android.com/reference/android/app/appsearch/SearchResult.TextMatchInfo`, this returns "Testing 1 2 3".

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/String` | This value cannot be `null`. <br /> |

### getSnippet

Added in [version 36.1](https://developer.android.com/topic/libraries/support-library/revisions)  
Also in [T Extensions 18](https://developer.android.com/sdkExtensions)

```
public CharSequence getSnippet ()
```

Gets the snippet corresponding to the given entry.

Snippet - Provides a subset of the content to display. Only populated when requested
maxSnippetSize \> 0. The size of this content can be changed by `https://developer.android.com/reference/android/app/appsearch/SearchSpec.Builder#setMaxSnippetSize(int)`. Windowing is centered around the middle of the
matched token with content on either side clipped to token boundaries.

Class example 1: this returns "foo. Another".

Class example 2: for the first `https://developer.android.com/reference/android/app/appsearch/SearchResult.TextMatchInfo`, this returns "Test Name" and,
for the second `https://developer.android.com/reference/android/app/appsearch/SearchResult.TextMatchInfo`, this returns "Testing 1 2 3".

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/CharSequence` | This value cannot be `null`. <br /> |

### getSnippetRange

Added in [version 36.1](https://developer.android.com/topic/libraries/support-library/revisions)  
Also in [T Extensions 18](https://developer.android.com/sdkExtensions)

```
public SearchResult.MatchRange getSnippetRange ()
```

Gets the snippet `https://developer.android.com/reference/android/app/appsearch/SearchResult.TextMatchInfo` corresponding to the given entry.

Only populated when set maxSnippetSize \> 0 in `https://developer.android.com/reference/android/app/appsearch/SearchSpec.Builder#setMaxSnippetSize(int)`.

Class example 1: this returns \[29, 41\].

Class example 2: for the first `https://developer.android.com/reference/android/app/appsearch/SearchResult.TextMatchInfo`, this returns \[0, 9\] and, for the
second `https://developer.android.com/reference/android/app/appsearch/SearchResult.TextMatchInfo`, this returns \[0, 13\].

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/app/appsearch/SearchResult.MatchRange` | This value cannot be `null`. <br /> |

### getSubmatch

Added in [version 36.1](https://developer.android.com/topic/libraries/support-library/revisions)  
Also in [T Extensions 18](https://developer.android.com/sdkExtensions)

```
public CharSequence getSubmatch ()
```

Gets the exact term subsequence of the given entry that matched the query.

Class example 1: this returns "foo".

Class example 2: for the first `https://developer.android.com/reference/android/app/appsearch/SearchResult.TextMatchInfo`, this returns "Test" and, for the
second `https://developer.android.com/reference/android/app/appsearch/SearchResult.TextMatchInfo`, this returns "Test".

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/CharSequence` | This value cannot be `null`. <br /> |

### getSubmatchRange

Added in [version 36.1](https://developer.android.com/topic/libraries/support-library/revisions)  
Also in [T Extensions 18](https://developer.android.com/sdkExtensions)

```
public SearchResult.MatchRange getSubmatchRange ()
```

Gets the `https://developer.android.com/reference/android/app/appsearch/SearchResult.MatchRange` of the exact term subsequence of the given entry that matched
the query.

Class example 1: this returns \[29, 32\].

Class example 2: for the first `https://developer.android.com/reference/android/app/appsearch/SearchResult.TextMatchInfo`, this returns \[0, 4\] and, for the
second `https://developer.android.com/reference/android/app/appsearch/SearchResult.TextMatchInfo`, this returns \[0, 4\].

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/app/appsearch/SearchResult.MatchRange` | This value cannot be `null`. <br /> |

### writeToParcel

Added in [version 36.1](https://developer.android.com/topic/libraries/support-library/revisions)

```
public void writeToParcel (Parcel dest, 
                int flags)
```

Flatten this object in to a Parcel.

<br />

| Parameters ||
|---|---|
| `dest` | `Parcel`: This value cannot be `null`. <br /> |
| `flags` | `int`: Additional flags about how the object should be written. May be 0 or `https://developer.android.com/reference/android/os/Parcelable#PARCELABLE_WRITE_RETURN_VALUE`. Value is either `0` or a combination of the following: - `https://developer.android.com/reference/android/os/Parcelable#PARCELABLE_WRITE_RETURN_VALUE` |