Added in [API level 36.1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  
Also in [T Extensions 18](https://developer.android.com/sdkExtensions)

# TextMatchInfo

*** ** * ** ***

```
class TextMatchInfo : Parcelable
```

|---|---|
| [kotlin.Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html) ||
| ↳ | [android.app.appsearch.SearchResult.TextMatchInfo](https://developer.android.com/reference/kotlin/android/app/appsearch/SearchResult.TextMatchInfo#) |

This class represents match objects for any text match snippets that might be present in `https://developer.android.com/reference/kotlin/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/kotlin/android/app/appsearch/SearchSpec.Builder#setMaxSnippetSize(kotlin.Int)`

for each text match in the document.

<br />

Class Example 1:

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

"A commonly used fake word is foo. Another nonsense word that's used a lot is bar."

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

- `https://developer.android.com/reference/kotlin/android/app/appsearch/SearchResult.TextMatchInfo#getFullText()` returns "A commonly used fake word is foo. Another nonsense word that's used a lot is bar."
- `https://developer.android.com/reference/kotlin/android/app/appsearch/SearchResult.TextMatchInfo#getExactMatchRange()` returns \[29, 32\]
- `https://developer.android.com/reference/kotlin/android/app/appsearch/SearchResult.TextMatchInfo#getExactMatch()` returns "foo"
- `https://developer.android.com/reference/kotlin/android/app/appsearch/SearchResult.TextMatchInfo#getSubmatchRange()` returns \[29, 32\]
- `https://developer.android.com/reference/kotlin/android/app/appsearch/SearchResult.TextMatchInfo#getSubmatch()` returns "foo"
- `https://developer.android.com/reference/kotlin/android/app/appsearch/SearchResult.TextMatchInfo#getSnippetRange()` returns \[26, 33\]
- `https://developer.android.com/reference/kotlin/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/kotlin/android/app/appsearch/SearchSpec#TERM_MATCH_PREFIX:kotlin.Int` and `https://developer.android.com/reference/kotlin/android/app/appsearch/SearchSpec#getMaxSnippetSize()` is 10. We will have 2 matches:

Match-1

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

Match-2

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

## Summary

| Inherited constants ||
|---|---|
| From class `https://developer.android.com/reference/kotlin/android/os/Parcelable.html#` |---|---| | `https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/android/os/Parcelable.html#CONTENTS_FILE_DESCRIPTOR:kotlin.Int` Descriptor bit used with `https://developer.android.com/reference/kotlin/android/os/Parcelable.html#describeContents()`: indicates that the Parcelable object's flattened representation includes a file descriptor. <br /> | | `https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/android/os/Parcelable.html#PARCELABLE_WRITE_RETURN_VALUE:kotlin.Int` Flag for use with `https://developer.android.com/reference/kotlin/android/os/Parcelable.html#writeToParcel(android.os.Parcel,%20kotlin.Int)`: 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)`". Some implementations may want to release resources at this point. <br /> | ||

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

| Public methods ||
|---|---|
| [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) | `https://developer.android.com/reference/kotlin/android/app/appsearch/SearchResult.TextMatchInfo#describeContents()()` Describe the kinds of special objects contained in this Parcelable instance's marshaled representation. |
| [CharSequence](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-char-sequence/index.html) | `https://developer.android.com/reference/kotlin/android/app/appsearch/SearchResult.TextMatchInfo#getExactMatch()()` Gets the exact term of the given entry that matched the query. |
| [SearchResult.MatchRange](https://developer.android.com/reference/kotlin/android/app/appsearch/SearchResult.MatchRange) | `https://developer.android.com/reference/kotlin/android/app/appsearch/SearchResult.TextMatchInfo#getExactMatchRange()()` Gets the `https://developer.android.com/reference/kotlin/android/app/appsearch/SearchResult.MatchRange` of the exact term of the given entry that matched the query. |
| [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html) | `https://developer.android.com/reference/kotlin/android/app/appsearch/SearchResult.TextMatchInfo#getFullText()()` Gets the full text corresponding to the given entry. |
| [CharSequence](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-char-sequence/index.html) | `https://developer.android.com/reference/kotlin/android/app/appsearch/SearchResult.TextMatchInfo#getSnippet()()` Gets the snippet corresponding to the given entry. |
| [SearchResult.MatchRange](https://developer.android.com/reference/kotlin/android/app/appsearch/SearchResult.MatchRange) | `https://developer.android.com/reference/kotlin/android/app/appsearch/SearchResult.TextMatchInfo#getSnippetRange()()` Gets the snippet `https://developer.android.com/reference/kotlin/android/app/appsearch/SearchResult.TextMatchInfo#` corresponding to the given entry. |
| [CharSequence](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-char-sequence/index.html) | `https://developer.android.com/reference/kotlin/android/app/appsearch/SearchResult.TextMatchInfo#getSubmatch()()` Gets the exact term subsequence of the given entry that matched the query. |
| [SearchResult.MatchRange](https://developer.android.com/reference/kotlin/android/app/appsearch/SearchResult.MatchRange) | `https://developer.android.com/reference/kotlin/android/app/appsearch/SearchResult.TextMatchInfo#getSubmatchRange()()` Gets the `https://developer.android.com/reference/kotlin/android/app/appsearch/SearchResult.MatchRange` of the exact term subsequence of the given entry that matched the query. |
| [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) | `https://developer.android.com/reference/kotlin/android/app/appsearch/SearchResult.TextMatchInfo#writeToParcel(android.os.Parcel,%20kotlin.Int)(dest: https://developer.android.com/reference/kotlin/android/os/Parcel.html#, flags: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)` Flatten this object in to a Parcel. |

| Properties ||
|---|---|
| static [Parcelable.Creator](https://developer.android.com/reference/kotlin/android/os/Parcelable.Creator.html#)\<[SearchResult.TextMatchInfo](https://developer.android.com/reference/kotlin/android/app/appsearch/SearchResult.TextMatchInfo#)!\> | `https://developer.android.com/reference/kotlin/android/app/appsearch/SearchResult.TextMatchInfo#CREATOR:android.os.Parcelable.Creator` <br /> |

## Public constructors

### TextMatchInfo

Added in [API level 36.1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  
Also in [T Extensions 18](https://developer.android.com/sdkExtensions)

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

Creates a new immutable TextMatchInfo.

| Parameters ||
|---|---|
| `exactMatchRange` | [SearchResult.MatchRange](https://developer.android.com/reference/kotlin/android/app/appsearch/SearchResult.MatchRange): the exact `https://developer.android.com/reference/kotlin/android/app/appsearch/SearchResult.MatchRange` for the entry. This value cannot be `null`. |
| `submatchRange` | [SearchResult.MatchRange](https://developer.android.com/reference/kotlin/android/app/appsearch/SearchResult.MatchRange): the sub-match `https://developer.android.com/reference/kotlin/android/app/appsearch/SearchResult.MatchRange` for the entry. This value cannot be `null`. |
| `snippetRange` | [SearchResult.MatchRange](https://developer.android.com/reference/kotlin/android/app/appsearch/SearchResult.MatchRange): the snippet `https://developer.android.com/reference/kotlin/android/app/appsearch/SearchResult.MatchRange` for the entry. This value cannot be `null`. |

## Public methods

### describeContents

Added in [API level 36.1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

```
fun describeContents(): Int
```

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/kotlin/android/os/Parcelable.html#writeToParcel(android.os.Parcel,%20kotlin.Int)`, the return value of this method must include the `https://developer.android.com/reference/kotlin/android/os/Parcelable.html#CONTENTS_FILE_DESCRIPTOR:kotlin.Int` bit.

| Return ||
|---|---|
| `https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html` | 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/kotlin/android/os/Parcelable.html#CONTENTS_FILE_DESCRIPTOR:kotlin.Int` |

### getExactMatch

Added in [API level 36.1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  
Also in [T Extensions 18](https://developer.android.com/sdkExtensions)

```
fun getExactMatch(): CharSequence
```

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/kotlin/android/app/appsearch/SearchResult.TextMatchInfo#`, this returns "Test" and, for the second `https://developer.android.com/reference/kotlin/android/app/appsearch/SearchResult.TextMatchInfo#`, this returns "Testing".

| Return ||
|---|---|
| `https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-char-sequence/index.html` | This value cannot be `null`. |

### getExactMatchRange

Added in [API level 36.1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  
Also in [T Extensions 18](https://developer.android.com/sdkExtensions)

```
fun getExactMatchRange(): SearchResult.MatchRange
```

Gets the `https://developer.android.com/reference/kotlin/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/kotlin/android/app/appsearch/SearchResult.TextMatchInfo#`, this returns \[0, 4\] and, for the second `https://developer.android.com/reference/kotlin/android/app/appsearch/SearchResult.TextMatchInfo#`, this returns \[0, 7\].

| Return ||
|---|---|
| `https://developer.android.com/reference/kotlin/android/app/appsearch/SearchResult.MatchRange` | This value cannot be `null`. |

### getFullText

Added in [API level 36.1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  
Also in [T Extensions 18](https://developer.android.com/sdkExtensions)

```
fun getFullText(): String
```

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/kotlin/android/app/appsearch/SearchResult.TextMatchInfo#`, this returns "Test Name Jr." and, for the second `https://developer.android.com/reference/kotlin/android/app/appsearch/SearchResult.TextMatchInfo#`, this returns "Testing 1 2 3".

| Return ||
|---|---|
| `https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html` | This value cannot be `null`. |

### getSnippet

Added in [API level 36.1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  
Also in [T Extensions 18](https://developer.android.com/sdkExtensions)

```
fun getSnippet(): CharSequence
```

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/kotlin/android/app/appsearch/SearchSpec.Builder#setMaxSnippetSize(kotlin.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/kotlin/android/app/appsearch/SearchResult.TextMatchInfo#`, this returns "Test Name" and, for the second `https://developer.android.com/reference/kotlin/android/app/appsearch/SearchResult.TextMatchInfo#`, this returns "Testing 1 2 3".

| Return ||
|---|---|
| `https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-char-sequence/index.html` | This value cannot be `null`. |

### getSnippetRange

Added in [API level 36.1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  
Also in [T Extensions 18](https://developer.android.com/sdkExtensions)

```
fun getSnippetRange(): SearchResult.MatchRange
```

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

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

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

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

| Return ||
|---|---|
| `https://developer.android.com/reference/kotlin/android/app/appsearch/SearchResult.MatchRange` | This value cannot be `null`. |

### getSubmatch

Added in [API level 36.1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  
Also in [T Extensions 18](https://developer.android.com/sdkExtensions)

```
fun getSubmatch(): CharSequence
```

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/kotlin/android/app/appsearch/SearchResult.TextMatchInfo#`, this returns "Test" and, for the second `https://developer.android.com/reference/kotlin/android/app/appsearch/SearchResult.TextMatchInfo#`, this returns "Test".

| Return ||
|---|---|
| `https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-char-sequence/index.html` | This value cannot be `null`. |

### getSubmatchRange

Added in [API level 36.1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  
Also in [T Extensions 18](https://developer.android.com/sdkExtensions)

```
fun getSubmatchRange(): SearchResult.MatchRange
```

Gets the `https://developer.android.com/reference/kotlin/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/kotlin/android/app/appsearch/SearchResult.TextMatchInfo#`, this returns \[0, 4\] and, for the second `https://developer.android.com/reference/kotlin/android/app/appsearch/SearchResult.TextMatchInfo#`, this returns \[0, 4\].

| Return ||
|---|---|
| `https://developer.android.com/reference/kotlin/android/app/appsearch/SearchResult.MatchRange` | This value cannot be `null`. |

### writeToParcel

Added in [API level 36.1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

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

Flatten this object in to a Parcel.

| Parameters ||
|---|---|
| `dest` | [Parcel](https://developer.android.com/reference/kotlin/android/os/Parcel.html#): This value cannot be `null`. |
| `flags` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html): Additional flags about how the object should be written. May be 0 or `https://developer.android.com/reference/kotlin/android/os/Parcelable.html#PARCELABLE_WRITE_RETURN_VALUE:kotlin.Int`. Value is either `0` or a combination of the following: - `https://developer.android.com/reference/kotlin/android/os/Parcelable.html#PARCELABLE_WRITE_RETURN_VALUE:kotlin.Int` |

## Properties

### CREATOR

Added in [API level 36.1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  
Also in [T Extensions 18](https://developer.android.com/sdkExtensions)

```
static val CREATOR: Parcelable.Creator<SearchResult.TextMatchInfo!>
```