public class SearchSession extends Object
You can obtain a search session by calling SearchAbility#beginSearch(String, String)
and perform search operations. If the search session is no longer needed,
call SearchAbility#endSearch(String, String, SearchSession) to end the session
and release resources. This class is thread-safe. A search session can be used by multiple threads.
SystemCapability.Data#DATA_SEARCH| 限定符和类型 | 方法 | 说明 |
|---|---|---|
int |
getSearchHitCount(String queryJsonStr) |
Obtains the number of results matching a specified string.
|
List<Recommendation> |
groupSearch(String queryJsonStr,
int groupLimit) |
Obtains and groups the results matching a specified string.
|
List<IndexData> |
search(String queryJsonStr,
int start,
int limit) |
Obtains the results matching a specified string on a page.
|
public int getSearchHitCount(String queryJsonStr)
This method quickly returns the number of matched results. After obtaining this number,
you can call search(java.lang.String,int,int) to perform a pagination search.
queryJsonStr - Indicates the string to match.public List<IndexData> search(String queryJsonStr, int start, int limit)
This method is generally called after the total number of results matching
a specified string is obtained using getSearchHitCount(java.lang.String).
queryJsonStr - Indicates the string to match.start - Indicates the index of the first matched result in the result set.
The value starts from 0. If the value is greater than the
total number of matched results, an empty list will be returned.limit - Indicates the maximum number of results allowed on this page.
The value cannot exceed 10,000.public List<Recommendation> groupSearch(String queryJsonStr, int groupLimit)
The matched results are grouped based on fields. The recommended maximum number
of groups returned for each field (Recommendation)
is specified by groupLimit.
queryJsonStr - Indicates the string to match.groupLimit - Indicates the maximum number of groups returned for each field.