use of com.enonic.xp.query.suggester.SuggestionQuery in project xp by enonic.
the class SuggestionQueryBuilderFactory method doCreate.
private Set<SuggestBuilder.SuggestionBuilder> doCreate(final SuggestionQueries suggestionQueries) {
Set<SuggestBuilder.SuggestionBuilder> suggestionBuilders = new HashSet<>();
for (final SuggestionQuery suggestionQuery : suggestionQueries) {
final SuggestBuilder.SuggestionBuilder suggestionBuilder;
if (suggestionQuery instanceof TermSuggestionQuery) {
suggestionBuilder = new TermSuggestionQueryBuilderFactory(fieldNameResolver).create((TermSuggestionQuery) suggestionQuery);
} else {
throw new IllegalArgumentException("Unexpected suggestion type: " + suggestionQuery.getClass());
}
suggestionBuilders.add(suggestionBuilder);
}
return suggestionBuilders;
}
use of com.enonic.xp.query.suggester.SuggestionQuery in project xp by enonic.
the class QuerySuggestionParams method getSuggestions.
public SuggestionQueries getSuggestions(final Map<String, Object> suggestionsMap) {
if (suggestionsMap == null) {
return SuggestionQueries.empty();
}
final SuggestionQueries.Builder suggestionQueries = SuggestionQueries.create();
suggestionsMap.forEach((name, suggestionQueryMap) -> {
final SuggestionQuery suggestionQuery = suggestionQueryFromParams(name, (Map<String, Object>) suggestionQueryMap);
if (suggestionQuery != null) {
suggestionQueries.add(suggestionQuery);
}
});
return suggestionQueries.build();
}
Aggregations