forked from hibernate/hibernate-search
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
82 additions
and
0 deletions.
There are no files selected for viewing
47 changes: 47 additions & 0 deletions
47
...main/java/org/hibernate/search/engine/search/aggregation/dsl/SumAggregationFieldStep.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/* | ||
* Hibernate Search, full-text search for your domain model | ||
* | ||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later | ||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>. | ||
*/ | ||
package org.hibernate.search.engine.search.aggregation.dsl; | ||
|
||
import java.util.Map; | ||
import java.util.function.Function; | ||
|
||
import org.hibernate.search.engine.search.common.ValueConvert; | ||
import org.hibernate.search.engine.search.predicate.dsl.SearchPredicateFactory; | ||
|
||
/** | ||
* The initial step in a "sum" aggregation definition, where the target field can be set. | ||
* | ||
* @param <PDF> The type of factory used to create predicates in {@link AggregationFilterStep#filter(Function)}. | ||
*/ | ||
public interface SumAggregationFieldStep<PDF extends SearchPredicateFactory> { | ||
|
||
/** | ||
* Target the given field in the sum aggregation. | ||
* | ||
* @param fieldPath The <a href="SearchAggregationFactory.html#field-paths">path</a> to the index field to aggregate. | ||
* @param type The type of field values. | ||
* @param <F> The type of field values. | ||
* @return The next step. | ||
*/ | ||
default <F> SumAggregationOptionStep<?, PDF, F, Map<F, Long>> field(String fieldPath, Class<F> type) { | ||
return field( fieldPath, type, ValueConvert.YES ); | ||
} | ||
|
||
/** | ||
* Target the given field in the sum aggregation. | ||
* | ||
* @param fieldPath The <a href="SearchAggregationFactory.html#field-paths">path</a> to the index field to aggregate. | ||
* @param type The type of field values. | ||
* @param <F> The type of field values. | ||
* @param convert Controls how the ranges passed to the next steps and fetched from the backend should be converted. | ||
* See {@link ValueConvert}. | ||
* @return The next step. | ||
*/ | ||
<F> SumAggregationOptionStep<?, PDF, F, Map<F, Long>> field(String fieldPath, Class<F> type, | ||
ValueConvert convert); | ||
|
||
} |
35 changes: 35 additions & 0 deletions
35
...ain/java/org/hibernate/search/engine/search/aggregation/dsl/SumAggregationOptionStep.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/* | ||
* Hibernate Search, full-text search for your domain model | ||
* | ||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later | ||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>. | ||
*/ | ||
package org.hibernate.search.engine.search.aggregation.dsl; | ||
|
||
import java.util.function.Function; | ||
|
||
import org.hibernate.search.engine.search.predicate.dsl.SearchPredicateFactory; | ||
|
||
/** | ||
* The final step in a "sum" aggregation definition, where optional parameters can be set. | ||
* | ||
* @param <S> The "self" type (the actual exposed type of this step). | ||
* @param <PDF> The type of factory used to create predicates in {@link #filter(Function)}. | ||
* @param <F> The type of the targeted field. | ||
* @param <A> The type of result for this aggregation. | ||
*/ | ||
public interface SumAggregationOptionStep< | ||
S extends SumAggregationOptionStep<?, PDF, F, A>, | ||
PDF extends SearchPredicateFactory, | ||
F, | ||
A> | ||
extends AggregationFinalStep<A>, AggregationFilterStep<S, PDF> { | ||
|
||
/** | ||
* @param missing The value to use, in case of the field value is (missing) not present, in place of "null" to compute the sum. | ||
* | ||
* @return {@code this}, for method chaining. | ||
*/ | ||
S missing(F missing); | ||
|
||
} |