# Print output for @column tags ?> SearchResult.MatchInfo - Android SDK | Android Developers

Most visited

Recently visited

SearchResult.MatchInfo

public static final class SearchResult.MatchInfo
extends Object

java.lang.Object
   ↳ android.app.appsearch.SearchResult.MatchInfo


This class represents a match objects for any Snippets that might be present in SearchResults from query. Using this class user can get the full text, exact matches and Snippets of document content for a given match.

Class Example 1: A document contains 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".

MatchInfo#getPropertyPath() returns "subject"

MatchInfo#getFullText() returns "A commonly used fake word is foo. Another nonsense word that’s used a lot is bar."

MatchInfo#getExactMatchRange() returns [29, 32]

MatchInfo#getExactMatch() returns "foo"

MatchInfo#getSnippetRange() returns [26, 33]

MatchInfo#getSnippet() returns "is foo."

Class Example 2: A document contains a property name sender which contains 2 property names name and email, so we will have 2 property paths: sender.name and sender.email.

Let sender.name = "Test Name Jr." and sender.email = "TestNameJr@gmail.com"

If the queryExpression is "Test". We will have 2 matches.

Match-1

MatchInfo#getPropertyPath() returns "sender.name"

MatchInfo#getFullText() returns "Test Name Jr."

MatchInfo#getExactMatchRange() returns [0, 4]

MatchInfo#getExactMatch() returns "Test"

MatchInfo#getSnippetRange() returns [0, 9]

MatchInfo#getSnippet() returns "Test Name"

Match-2

MatchInfo#getPropertyPath() returns "sender.email"

MatchInfo#getFullText() returns "TestNameJr@gmail.com"

MatchInfo#getExactMatchRange() returns [0, 20]

MatchInfo#getExactMatch() returns "TestNameJr@gmail.com"

MatchInfo#getSnippetRange() returns [0, 20]

MatchInfo#getSnippet() returns "TestNameJr@gmail.com"

Summary

Nested classes

class SearchResult.MatchInfo.Builder

Builder for MatchInfo objects. 

Public methods

CharSequence getExactMatch()

Gets the MatchRange corresponding to the given entry.

SearchResult.MatchRange getExactMatchRange()

Gets the exact MatchRange corresponding to the given entry.

String getFullText()

Gets the full text corresponding to the given entry.

String getPropertyPath()

Gets the property path corresponding to the given entry.

CharSequence getSnippet()

Gets the snippet corresponding to the given entry.

SearchResult.MatchRange getSnippetRange()

Gets the snippet MatchRange corresponding to the given entry.

Inherited methods

Public methods

getExactMatch

public CharSequence getExactMatch ()

Gets the MatchRange corresponding to the given entry.

For class example 1 this returns "foo"

Returns
CharSequence This value cannot be null.

getExactMatchRange

public SearchResult.MatchRange getExactMatchRange ()

Gets the exact MatchRange corresponding to the given entry.

For class example 1 this returns [29, 32]

Returns
SearchResult.MatchRange This value cannot be null.

getFullText

public String getFullText ()

Gets the full text corresponding to the given entry.

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

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.

getSnippet

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 SearchSpec.Builder.setMaxSnippetSize(int). Windowing is centered around the middle of the matched token with content on either side clipped to token boundaries.

For class example 1 this returns "foo. Another"

Returns
CharSequence This value cannot be null.

getSnippetRange

public SearchResult.MatchRange getSnippetRange ()

Gets the snippet MatchRange corresponding to the given entry.

Only populated when set maxSnippetSize > 0 in SearchSpec.Builder.setMaxSnippetSize(int).

For class example 1 this returns [29, 41].

Returns
SearchResult.MatchRange This value cannot be null.