Skip to main content
[ This file is autogenerated from apexdoc ]

AqSosl

Builder class for SOSL quieries.

Group apex/core

Methods​

public AqSosl withoutUserMode()​

Use it to omit WITH USER_MODE. Turned on by default.

public AqSosl setSearchScope(Scope scope)​

Parameters​

ParamDescription
scopeset of fields searched by the sosl query. See Scope

public AqSosl setSearchObjects(List<String> searchObjects)​

Sets the objects that will be queried.

Parameters​

ParamDescription
searchObjectsa list of SObject Type names.

public AqSosl setFieldsForObject(String objectName, List<String> fields)​

Sets the fields that will be returned in the search query for the given object.

Parameters​

ParamDescription
objectNamean SObject Type name
fieldsa list of field names

public AqSosl setLimitForObject(String objectName, Integer lmt)​

Sets the number of records to limit the search results for the given object.

Parameters​

ParamDescription
objectNamean SObject Type name
lmtan integer

public AqSosl setConditionForObject(String objectName, String condition)​

Sets the WHERE clause of a sosl search for the given object.

Parameters​

ParamDescription
objectNamean SObject Type name
conditionfilters for a Where clause

public AqSosl setOrderByForObject(String objectName, List<String> orderByItems)​

Sets the OREDER BY parameter of a sosl search for the given object.

Parameters​

ParamDescription
objectNamean SObject Type name
orderByItemslist of fields to order by

public Set<String> getSearchObjects()​

Returns​

TypeDescription
Set<String>a Set that contains the SObject types that will be queried.

public AqSosl find(String searchText)​

This method executes the SOSL search and updates the internal state with the results ( or error ).

Parameters​

ParamDescription
searchTextthe word or phrase to be searched.

Example​

List<String> FIELDS_FOR_SELECTION = {'Name'};
Integer SEARCH_RESULTS_LIMIT = 1000;
public static List<Account> searchAccounts(String searchText) {
String objectName = 'Account';
String condition = 'Name != NULL';
List<String> orderFields = {'Name'};
AqSosl sosl = new AqSosl()
.setSearchObjects(new List<String>{ objectName })
.setFieldsForObject(objectName, FIELDS_FOR_SELECTION)
.setLimitForObject(objectName, SEARCH_RESULTS_LIMIT)
.setConditionForObject(objectName, condition)
.setOrderByForObject(objectName, orderFields)
.find(searchText);
return sosl.getResultsForObject(objectName);
}

public List<SObject> getResultsForObject(String objectName)​

Parameters​

ParamDescription
objectNamean SObject Type name

Returns​

TypeDescription
List<SObject>a list of SObjects that were returned in the search.

public static List<SObject> getResultsForObject(String objectName, List<List<SObject>> soslResults)​

Parameters​

ParamDescription
objectNamean SObject Type name
soslResultsSosl search results

Returns​

TypeDescription
List<SObject>a list of SObjects that were returned in the search for a given SObject

public Map<String,List<SObject>> getResults()​

Returns​

TypeDescription
Map<String,List<SObject>>a list of all SObject lists that were returned in the query.

public String getSoslQuery(String searchText)​

Returns​

TypeDescription
Stringa SOSL query string

Enums​

Scope​

Search scope (Name fields, Email fields, all fields etc.)