[ 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
| Param | Description |
|---|---|
scope | set of fields searched by the sosl query. See Scope |
public AqSosl setSearchObjects(List<String> searchObjects)
Sets the objects that will be queried.
Parameters
| Param | Description |
|---|---|
searchObjects | a 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
| Param | Description |
|---|---|
objectName | an SObject Type name |
fields | a 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
| Param | Description |
|---|---|
objectName | an SObject Type name |
lmt | an integer |
public AqSosl setConditionForObject(String objectName, String condition)
Sets the WHERE clause of a sosl search for the given object.
Parameters
| Param | Description |
|---|---|
objectName | an SObject Type name |
condition | filters 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
| Param | Description |
|---|---|
objectName | an SObject Type name |
orderByItems | list of fields to order by |
public Set<String> getSearchObjects()
Returns
| Type | Description |
|---|---|
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
| Param | Description |
|---|---|
searchText | the 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
| Param | Description |
|---|---|
objectName | an SObject Type name |
Returns
| Type | Description |
|---|---|
List<SObject> | a list of SObjects that were returned in the search. |
public static List<SObject> getResultsForObject(String objectName, List<List<SObject>> soslResults)
Parameters
| Param | Description |
|---|---|
objectName | an SObject Type name |
soslResults | Sosl search results |
Returns
| Type | Description |
|---|---|
List<SObject> | a list of SObjects that were returned in the search for a given SObject |
public Map<String,List<SObject>> getResults()
Returns
| Type | Description |
|---|---|
Map<String,List<SObject>> | a list of all SObject lists that were returned in the query. |
public String getSoslQuery(String searchText)
Returns
| Type | Description |
|---|---|
String | a SOSL query string |
Enums
Scope
Search scope (Name fields, Email fields, all fields etc.)