public interface SuggestQuery extends SphereRequest<SuggestionResult>
final SearchKeywords searchKeywords = SearchKeywords.of(
Locale.ENGLISH, asList(SearchKeyword.of("Multi tool"),
SearchKeyword.of("Swiss Army Knife", WhiteSpaceSuggestTokenizer.of())),
Locale.GERMAN, singletonList(SearchKeyword.of("Schweizer Messer",
CustomSuggestTokenizer.of(asList("schweizer messer", "offiziersmesser", "sackmesser"))))
);
assertThat(product.getMasterData().getStaged().getSearchKeywords()).isEqualTo(searchKeywords);
final List<LocalizedStringEntry> keywords = asList(
LocalizedStringEntry.of(Locale.GERMAN, "offiz"),
LocalizedStringEntry.of(Locale.ENGLISH, "multi")
);
final SuggestQuery suggestQuery = SuggestQuery.of(keywords)
.withStaged(true);
assertEventually(Duration.ofSeconds(120), Duration.ofMillis(100), () -> {
final SuggestionResult suggestionResult = client().executeBlocking(suggestQuery);
assertThat(suggestionResult.getSuggestionsForLocale(Locale.GERMAN))
.matches(suggestionsList -> suggestionsList.stream()
.anyMatch(suggestion -> suggestion.getText().equals("Schweizer Messer")));
assertThat(suggestionResult.getSuggestionsForLocale(Locale.ENGLISH))
.matches(suggestionsList -> suggestionsList.stream()
.anyMatch(suggestion -> suggestion.getText().equals("Multi tool")));
});
See the test code.
Modifier and Type | Method and Description |
---|---|
static SuggestQuery |
of(List<LocalizedStringEntry> searchKeywords) |
static SuggestQuery |
of(LocalizedStringEntry searchKeyword) |
SuggestQuery |
withFuzzy(boolean fuzzy) |
SuggestQuery |
withLimit(Integer limit) |
SuggestQuery |
withStaged(boolean staged) |
canDeserialize, deserialize, httpRequestIntent
static SuggestQuery of(List<LocalizedStringEntry> searchKeywords)
static SuggestQuery of(LocalizedStringEntry searchKeyword)
SuggestQuery withLimit(Integer limit)
SuggestQuery withStaged(boolean staged)
SuggestQuery withFuzzy(boolean fuzzy)