# SearchResult.MatchInfo

Artifact: [androidx.appsearch:appsearch](https://developer.android.com/jetpack/androidx/releases/appsearch) [View Source](https://cs.android.com/search?q=file:androidx/appsearch/app/SearchResult.java+class:androidx.appsearch.app.SearchResult.MatchInfo) Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/appsearch#1.1.0)

*** ** * ** ***


```
public final class SearchResult.MatchInfo
```

<br />

*** ** * ** ***

This class represents match objects for any snippets that might be present in `https://developer.android.com/reference/androidx/appsearch/app/SearchResults` from a query.

A `https://developer.android.com/reference/androidx/appsearch/app/SearchResult.MatchInfo` contains either a `https://developer.android.com/reference/androidx/appsearch/app/SearchResult.TextMatchInfo` representing a text match snippet, or an `https://developer.android.com/reference/androidx/appsearch/app/SearchResult.EmbeddingMatchInfo` representing an embedding match snippet.

## Summary

| ### Nested types |
|---|
| `public final class https://developer.android.com/reference/androidx/appsearch/app/SearchResult.MatchInfo.Builder` Builder for `https://developer.android.com/reference/androidx/appsearch/app/SearchResult.MatchInfo` objects. |

| ### Public methods |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/androidx/appsearch/app/SearchResult.EmbeddingMatchInfo` | `@https://developer.android.com/reference/androidx/appsearch/app/ExperimentalAppSearchApi https://developer.android.com/reference/androidx/appsearch/app/SearchResult.MatchInfo#getEmbeddingMatch()()` Retrieves the embedding-based match information. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/CharSequence.html` | `https://developer.android.com/reference/androidx/appsearch/app/SearchResult.MatchInfo#getExactMatch()()` Gets the exact term of the given entry that matched the query. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/appsearch/app/SearchResult.MatchRange` | `https://developer.android.com/reference/androidx/appsearch/app/SearchResult.MatchInfo#getExactMatchRange()()` Gets the `https://developer.android.com/reference/androidx/appsearch/app/SearchResult.MatchRange` of the exact term of the given entry that matched the query. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/appsearch/app/SearchResult.MatchInfo#getFullText()()` Gets the full text corresponding to the given entry. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/appsearch/app/SearchResult.MatchInfo#getPropertyPath()()` Gets the property path corresponding to the given entry. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/appsearch/app/PropertyPath` | `https://developer.android.com/reference/androidx/appsearch/app/SearchResult.MatchInfo#getPropertyPathObject()()` Gets a `https://developer.android.com/reference/androidx/appsearch/app/PropertyPath` object representing the property path corresponding to the given entry. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/CharSequence.html` | `https://developer.android.com/reference/androidx/appsearch/app/SearchResult.MatchInfo#getSnippet()()` Gets the snippet corresponding to the given entry. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/appsearch/app/SearchResult.MatchRange` | `https://developer.android.com/reference/androidx/appsearch/app/SearchResult.MatchInfo#getSnippetRange()()` Gets the snippet `https://developer.android.com/reference/androidx/appsearch/app/SearchResult.MatchRange` corresponding to the given entry. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/CharSequence.html` | `@https://developer.android.com/reference/androidx/annotation/RequiresFeature(enforcement = "androidx.appsearch.app.Features#isFeatureSupported", name = https://developer.android.com/reference/androidx/appsearch/app/Features.SEARCH_RESULT_MATCH_INFO_SUBMATCH) https://developer.android.com/reference/androidx/appsearch/app/SearchResult.MatchInfo#getSubmatch()()` Gets the exact term subsequence of the given entry that matched the query. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/appsearch/app/SearchResult.MatchRange` | `@https://developer.android.com/reference/androidx/annotation/RequiresFeature(enforcement = "androidx.appsearch.app.Features#isFeatureSupported", name = https://developer.android.com/reference/androidx/appsearch/app/Features.SEARCH_RESULT_MATCH_INFO_SUBMATCH) https://developer.android.com/reference/androidx/appsearch/app/SearchResult.MatchInfo#getSubmatchRange()()` Gets the `https://developer.android.com/reference/androidx/appsearch/app/SearchResult.MatchRange` of the submatch term subsequence of the given entry that matched the query. |
| `@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/androidx/appsearch/app/SearchResult.TextMatchInfo` | `@https://developer.android.com/reference/androidx/appsearch/app/ExperimentalAppSearchApi https://developer.android.com/reference/androidx/appsearch/app/SearchResult.MatchInfo#getTextMatch()()` Retrieves the text-based match information. |

## Public methods

### getEmbeddingMatch

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/appsearch#1.1.0)

```
@ExperimentalAppSearchApi
public @Nullable SearchResult.EmbeddingMatchInfo getEmbeddingMatch()
```

Retrieves the embedding-based match information. Only populated when `https://developer.android.com/reference/androidx/appsearch/app/SearchSpec#shouldRetrieveEmbeddingMatchInfos()` is true.

| Returns |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/androidx/appsearch/app/SearchResult.EmbeddingMatchInfo` | A `https://developer.android.com/reference/androidx/appsearch/app/SearchResult.EmbeddingMatchInfo` instance, or null if the match is not an embedding match. |

### getExactMatch

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/appsearch#1.1.0)

```
public @NonNull 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.

### getExactMatchRange

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/appsearch#1.1.0)

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

Gets the `https://developer.android.com/reference/androidx/appsearch/app/SearchResult.MatchRange` of the exact term of the given entry that matched the query. Returns \[0, 0\] if the match is not text-based.

### getFullText

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/appsearch#1.1.0)

```
public @NonNull String getFullText()
```

Gets the full text corresponding to the given entry. Returns an empty string if the match is not text-based.

### getPropertyPath

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/appsearch#1.1.0)

```
public @NonNull 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"

### getPropertyPathObject

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/appsearch#1.1.0)

```
public @NonNull PropertyPath getPropertyPathObject()
```

Gets a `https://developer.android.com/reference/androidx/appsearch/app/PropertyPath` object representing the property path corresponding to the given entry.

Methods such as `https://developer.android.com/reference/androidx/appsearch/app/GenericDocument#getPropertyDocument(java.lang.String)` accept a path as a string rather than a `https://developer.android.com/reference/androidx/appsearch/app/PropertyPath` object. However, you may want to manipulate the path before getting a property document. This method returns a `https://developer.android.com/reference/androidx/appsearch/app/PropertyPath` rather than a String for easier path manipulation, which can then be converted to a String.

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/appsearch/app/SearchResult.MatchInfo#getPropertyPath()` |   |
| `https://developer.android.com/reference/androidx/appsearch/app/PropertyPath` |   |

### getSnippet

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/appsearch#1.1.0)

```
public @NonNull 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 `https://developer.android.com/reference/androidx/appsearch/app/SearchSpec.Builder#setMaxSnippetSize(int)`. Windowing is centered around the middle of the matched token with content on either side clipped to token boundaries.

### getSnippetRange

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/appsearch#1.1.0)

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

Gets the snippet `https://developer.android.com/reference/androidx/appsearch/app/SearchResult.MatchRange` corresponding to the given entry. Returns \[0,0\] if the match is not text-based.

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

### getSubmatch

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/appsearch#1.1.0)

```
@RequiresFeature(enforcement = "androidx.appsearch.app.Features#isFeatureSupported", name = Features.SEARCH_RESULT_MATCH_INFO_SUBMATCH)
public @NonNull 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.

This information may not be available depending on the backend and Android API level. To ensure it is available, call `https://developer.android.com/reference/androidx/appsearch/app/Features#isFeatureSupported(java.lang.String)`.

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/UnsupportedOperationException.html` | if `https://developer.android.com/reference/androidx/appsearch/app/Features#isFeatureSupported(java.lang.String)` is false. |

### getSubmatchRange

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/appsearch#1.1.0)

```
@RequiresFeature(enforcement = "androidx.appsearch.app.Features#isFeatureSupported", name = Features.SEARCH_RESULT_MATCH_INFO_SUBMATCH)
public @NonNull SearchResult.MatchRange getSubmatchRange()
```

Gets the `https://developer.android.com/reference/androidx/appsearch/app/SearchResult.MatchRange` of the submatch term subsequence of the given entry that matched the query. Returns \[0, 0\] if the match is not text-based.

This information may not be available depending on the backend and Android API level. To ensure it is available, call `https://developer.android.com/reference/androidx/appsearch/app/Features#isFeatureSupported(java.lang.String)`.

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/UnsupportedOperationException.html` | if `https://developer.android.com/reference/androidx/appsearch/app/Features#isFeatureSupported(java.lang.String)` is false. |

### getTextMatch

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/appsearch#1.1.0)

```
@ExperimentalAppSearchApi
public @Nullable SearchResult.TextMatchInfo getTextMatch()
```

Retrieves the text-based match information.

| Returns |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/androidx/appsearch/app/SearchResult.TextMatchInfo` | A `https://developer.android.com/reference/androidx/appsearch/app/SearchResult.TextMatchInfo` instance, or null if the match is not text-based. |