use of com.enonic.xp.query.suggester.SuggestionQueries in project xp by enonic.
the class SuggestionQueriesTest method testEmpty.
@Test
public void testEmpty() {
final SuggestionQueries queries = SuggestionQueries.empty();
assertTrue(queries.isEmpty());
}
use of com.enonic.xp.query.suggester.SuggestionQueries in project xp by enonic.
the class SuggestionQueriesTest method testBuilder.
@Test
public void testBuilder() {
final TermSuggestionQuery query = TermSuggestionQuery.create("queryName").field("category").text("value").analyzer("analyzer").size(1).maxEdits(2).prefixLength(3).minWordLength(4).maxInspections(5).minDocFreq(6f).maxTermFreq(7f).sort(TermSuggestionQuery.Sort.FREQUENCY).suggestMode(TermSuggestionQuery.SuggestMode.ALWAYS).stringDistance(TermSuggestionQuery.StringDistance.INTERNAL).build();
final SuggestionQueries queries = SuggestionQueries.create().add(query).build();
assertNotNull(queries);
assertTrue(queries.isNotEmpty());
assertTrue(queries.contains(query));
}
use of com.enonic.xp.query.suggester.SuggestionQueries 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();
}
use of com.enonic.xp.query.suggester.SuggestionQueries in project xp by enonic.
the class AbstractFindNodesQueryHandler method createNodeQuery.
NodeQuery createNodeQuery() {
final int start = valueOrDefault(this.start, 0);
final int count = valueOrDefault(this.count, 10);
final QueryExpr queryExpr = QueryExpr.from(buildConstraintExpr(), buildOrderExpr());
final Filters filters = JsonToFilterMapper.create(this.filters);
final AggregationQueries aggregations = new QueryAggregationParams().getAggregations(this.aggregations);
final SuggestionQueries suggestions = new QuerySuggestionParams().getSuggestions(this.suggestions);
final HighlightQuery highlight = new QueryHighlightParams().getHighlightQuery(this.highlight);
return NodeQuery.create().from(start).size(count).addAggregationQueries(aggregations).addSuggestionQueries(suggestions).highlight(highlight).query(queryExpr).addQueryFilters(filters).explain(this.explain).build();
}
Aggregations