TopHitsAggregationBuilder topHits = AggregationBuilders.topHits(alias); List<KVValue> params = field.getParams(); String[] include = null;
private static TopHitsAggregationBuilder createSubAggregation(SuggestionQuery query) { return AggregationBuilders.topHits(DOCS_AGGREGATION_NAME) .highlighter(new HighlightBuilder() .encoder("html") .preTags("<mark>") .postTags("</mark>") .field(createHighlighterField())) .from(query.getSkip()) .size(query.getLimit()) .sort(new ScoreSortBuilder()) .sort(new FieldSortBuilder(ComponentIndexDefinition.FIELD_NAME)) .fetchSource(false); }
/** * Gets the top hits aggregation. * * @param selectStatement * the select statement * @param size * the size * @param entityMetadata * the entity metadata * @return the top hits aggregation */ private TopHitsBuilder getTopHitsAggregation(SelectStatement selectStatement, Integer size, EntityMetadata entityMetadata) { TopHitsBuilder topHitsBuilder = AggregationBuilders.topHits(ESConstants.TOP_HITS); if (size != null) { topHitsBuilder.setSize(size); } return topHitsBuilder; }
/** * Gets the top hits aggregation. * * @param selectStatement * the select statement * @param size * the size * @param entityMetadata * the entity metadata * @return the top hits aggregation */ private TopHitsBuilder getTopHitsAggregation(SelectStatement selectStatement, Integer size, EntityMetadata entityMetadata) { TopHitsBuilder topHitsBuilder = AggregationBuilders.topHits(ESConstants.TOP_HITS); if (size != null) { topHitsBuilder.setSize(size); } return topHitsBuilder; }
TopHitsAggregationBuilder topHits = AggregationBuilders.topHits(alias); List<KVValue> params = field.getParams(); String[] include = null;
AggregationBuilders.topHits(TOP_HITS_AGGREGATION_NAME) .fetchSource(new String[]{propertyName}, new String[0]) .size(1)
AggregationBuilders.topHits(TOP_HITS_AGGREGATION_NAME) .fetchSource(new String[]{propertyName}, new String[0]) .size(1)
.terms("partition").field(partitionField).size(maxBucketNum); TopHitsAggregationBuilder tophits = AggregationBuilders.topHits("docs") .size(maxURLsPerBucket).explain(false);
TopHitsBuilder topHitsBuilder = AggregationBuilders.topHits(HITS_AGGREGATION) .setFrom(0) .setSize(1);
private static TopHitsAggregationBuilder createSubAggregation(SuggestionQuery query) { return AggregationBuilders.topHits(DOCS_AGGREGATION_NAME) .highlighter(new HighlightBuilder() .encoder("html") .preTags("<mark>") .postTags("</mark>") .field(createHighlighterField())) .from(query.getSkip()) .size(query.getLimit()) .sort(new ScoreSortBuilder()) .sort(new FieldSortBuilder(ComponentIndexDefinition.FIELD_NAME)) .fetchSource(false); }
.field("assets.attributes.npm.name") .size(v1SearchMaxResults) .subAggregation(AggregationBuilders.topHits("versions") .addSort(SortBuilders.fieldSort("assets.attributes.npm.search_normalized_version") .order(SortOrder.DESC))
private AggregationBuilder buildObjectsAggregation(FactSearchCriteria criteria) { // 1. Reduce to Facts matching the search criteria. return filter(FILTER_FACTS_AGGREGATION_NAME, buildFactsQuery(criteria)) // 2. Map to nested Object documents. .subAggregation(nested(NESTED_OBJECTS_AGGREGATION_NAME, "objects") // 3. Reduce to Objects matching the search criteria. .subAggregation(filter(FILTER_OBJECTS_AGGREGATION_NAME, buildObjectsQuery(criteria)) // 4. Calculate the number of unique Objects by id. This will give the 'count' value. // If 'count' is smaller than MAX_RESULT_WINDOW a correct value is expected, thus, // the precision threshold is set to MAX_RESULT_WINDOW. .subAggregation(cardinality(OBJECTS_COUNT_AGGREGATION_NAME) .field("objects.id") .precisionThreshold(MAX_RESULT_WINDOW) ) // 5. Reduce to buckets of unique Objects by id, restricted to the search criteria's limit. // This will give the actual search results. .subAggregation(terms(UNIQUE_OBJECTS_AGGREGATION_NAME) .field("objects.id") .size(calculateMaximumSize(criteria)) // 6. Map to the unique Object's source. Set size to 1, because all Objects in one // bucket are the same (ignoring 'direction' which isn't relevant for Object search). .subAggregation(topHits(UNIQUE_OBJECTS_SOURCE_AGGREGATION_NAME) .size(1) ) ) ) ); }
public FacetedSearchResult search(Class<? extends T> clazz, String query, Integer size, Map<String, String[]> filters) { TopHitsBuilder topHitAggregation = AggregationBuilders.topHits("highest_version").setSize(1) .addSort(new FieldSortBuilder("nestedVersion.majorVersion").order(SortOrder.DESC)) .addSort(new FieldSortBuilder("nestedVersion.minorVersion").order(SortOrder.DESC))