SearchAPIClient Apex class
SearchAPIClient Apex class
You can use this Apex classes to call the Coveo Search API.
|
|
Note
You should also consult the: |
Methods
querySuggestResponse
Represents the structure of a response from the QuerySuggestion API.
It contains the following attributes:
-
expression: The expression to complete the query. -
score: The score associated to the query suggestion. -
executableConfidence: The confidence ratio given by Coveo Machine Learning (Coveo ML).
querySuggest
Calls the API to request query suggestions (see querySuggestPost).
You can use the following params:
-
body: The body of thequerySuggestrequest. It should include at leastlocale,q, andsearchHub. -
authorization: The content of the Authorization header to send (for example,Bearer TOKEN).
String token = CoveoV2.Globals.generateSearchToken();
List<CoveoV2.SearchApiClient.QuerySuggestResponse> suggestions = CoveoV2.SearchApiClient.querySuggest(
new Map<String,Object>{
'locale' => 'en',
'q' => '',
'searchHub' => 'hub'
},
'Bearer ' + token);
System.debug(suggestions);
executeQuery
Executes a query to the organization currently linked to the package or any URI.
String token = CoveoV2.Globals.generateSearchToken();
CoveoV2.SearchApiResponse response = CoveoV2.SearchApiClient.executeQuery(
new Map<String,Object>{
'q' => 'my query text'
},
'Bearer ' + token);
System.debug(response);