Suggestion Candidates

Besides rule-based generation of suggestions, it is possible to ingest suggestion candidates into Ecommerce Search through the API using the /api/ingestion/segments/{segmentId}/suggestion-candidates endpoints.

As described in the page on suggestions, suggestion candidates are turned into suggestions by Ecommerce Search, providing suggestions for searches to customers searching with Ecommerce Search.

To create suggestion candidates use the following code sample:

private readonly ISearchAdministrationClientFactory _administrationClientFactory;

{...}

public async Task IngestCandidates(string segmentId, IEnumerable<CreateSuggestionCandidateModel> candidates){
    var client = await _administrationClientFactory.CreateAuthenticatedClientAsync();

    foreach (var candidate in candidates)
    {
        await client.CreateSuggestionCandidateAsync(segmentId, candidate);
    }
}

The CreateSuggestionCandidateModel has 3 required fields:

  • Datasource the source of the candidates, it could be "user_searches"
  • ExternalId, id that allowes to find the candidate again.
  • SuggestionText the suggestion that should be created, an example could be "watermelon" or "big watermelon"

If candidates are not needed anymore they can be deleted with the DeleteSuggestionCandidateAsync method.