public final class

SearchResult.MatchInfo

extends java.lang.Object

 java.lang.Object

↳androidx.appsearch.app.SearchResult.MatchInfo

Overview

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".

SearchResult.MatchInfo.getPropertyPath() returns "subject"

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

SearchResult.MatchInfo.getExactMatchRange() returns [29, 32]

SearchResult.MatchInfo.getExactMatch() returns "foo"

SearchResult.MatchInfo.getSubmatchRange() returns [29, 32]

SearchResult.MatchInfo.getSubmatch() returns "foo"

SearchResult.MatchInfo.getSnippetRange() returns [26, 33]

SearchResult.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

SearchResult.MatchInfo.getPropertyPath() returns "sender.name"

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

SearchResult.MatchInfo.getExactMatchRange() returns [0, 4]

SearchResult.MatchInfo.getExactMatch() returns "Test"

SearchResult.MatchInfo.getSubmatchRange() returns [0, 4]

SearchResult.MatchInfo.getSubmatch() returns "Test"

SearchResult.MatchInfo.getSnippetRange() returns [0, 9]

SearchResult.MatchInfo.getSnippet() returns "Test Name"

Match-2

SearchResult.MatchInfo.getPropertyPath() returns "sender.email"

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

SearchResult.MatchInfo.getExactMatchRange() returns [0, 20]

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

SearchResult.MatchInfo.getSubmatchRange() returns [0, 4]

SearchResult.MatchInfo.getSubmatch() returns "Test"

SearchResult.MatchInfo.getSnippetRange() returns [0, 20]

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

Summary

Methods
public java.lang.CharSequencegetExactMatch()

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

public SearchResult.MatchRangegetExactMatchRange()

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

public java.lang.StringgetFullText()

Gets the full text corresponding to the given entry.

public java.lang.StringgetPropertyPath()

Gets the property path corresponding to the given entry.

public java.lang.CharSequencegetSnippet()

Gets the snippet corresponding to the given entry.

public SearchResult.MatchRangegetSnippetRange()

Gets the snippet SearchResult.MatchRange corresponding to the given entry.

public java.lang.CharSequencegetSubmatch()

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

public SearchResult.MatchRangegetSubmatchRange()

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

from java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Methods

public java.lang.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"

public java.lang.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."

public SearchResult.MatchRange getExactMatchRange()

Gets the 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 SearchResult.MatchInfo, this returns [0, 4] and, for the second SearchResult.MatchInfo, this returns [0, 20].

public java.lang.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 SearchResult.MatchInfo, this returns "Test" and, for the second SearchResult.MatchInfo, this returns "TestNameJr@gmail.com".

public SearchResult.MatchRange getSubmatchRange()

Gets the 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 SearchResult.MatchInfo, this returns [0, 4] and, for the second SearchResult.MatchInfo, this returns [0, 4].

This information may not be available depending on the backend and Android API level. To ensure it is available, call Capabilities.isSubmatchSupported().

public java.lang.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 SearchResult.MatchInfo, this returns "Test" and, for the second SearchResult.MatchInfo, this returns "Test".

This information may not be available depending on the backend and Android API level. To ensure it is available, call Capabilities.isSubmatchSupported().

public SearchResult.MatchRange getSnippetRange()

Gets the snippet SearchResult.MatchRange corresponding to the given entry.

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

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

Class example 2: for the first SearchResult.MatchInfo, this returns [0, 9] and, for the second SearchResult.MatchInfo, this returns [0, 20].

public java.lang.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.

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

Class example 2: for the first SearchResult.MatchInfo, this returns "Test Name" and, for the second SearchResult.MatchInfo, this returns "TestNameJr@gmail.com".