Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
HSEARCH-3881 Expose the extended search predicate factory in extended…
… search aggregation factories I.e. make sure that this works: .search( ... ).extension( LuceneExtension.get() ) .where( ... ) .aggregation( f -> f.terms()... .filter( pf -> pf.fromLuceneQuery( ... ) ) ) ... and that we don't have to call .extension() again on "pf", because the provided factory is already extended.
- Loading branch information
Showing
27 changed files
with
281 additions
and
182 deletions.
There are no files selected for viewing
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
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
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
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
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
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
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
60 changes: 60 additions & 0 deletions
60
...c/main/java/org/hibernate/search/engine/search/aggregation/dsl/AggregationFilterStep.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,60 @@ | ||
/* | ||
* 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.SearchPredicate; | ||
import org.hibernate.search.engine.search.predicate.dsl.PredicateFinalStep; | ||
import org.hibernate.search.engine.search.predicate.dsl.SearchPredicateFactory; | ||
|
||
/** | ||
* The step in an aggregation definition where a filter can be set | ||
* to select nested objects from which values will be extracted for this aggregation. | ||
* | ||
* @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)}. | ||
*/ | ||
public interface AggregationFilterStep<S, PDF extends SearchPredicateFactory> { | ||
|
||
/** | ||
* Filter nested objects from which values will be extracted for this aggregation. | ||
* <p> | ||
* The filter is based on a previously-built {@link SearchPredicate}. | ||
* | ||
* @param searchPredicate The predicate that must match. | ||
* @return {@code this}, for method chaining. | ||
*/ | ||
S filter(SearchPredicate searchPredicate); | ||
|
||
/** | ||
* Filter nested objects from which values will be extracted for this aggregation. | ||
* <p> | ||
* The filter is defined by the given function. | ||
* <p> | ||
* Best used with lambda expressions. | ||
* | ||
* @param clauseContributor A function that will use the factory passed in parameter to create a predicate, | ||
* returning the final step in the predicate DSL. | ||
* Should generally be a lambda expression. | ||
* @return {@code this}, for method chaining. | ||
*/ | ||
S filter(Function<? super PDF, ? extends PredicateFinalStep> clauseContributor); | ||
|
||
/** | ||
* Filter nested objects from which values will be extracted for this aggregation. | ||
* <p> | ||
* The filter is based on an almost-built {@link SearchPredicate}. | ||
* | ||
* @param dslFinalStep A final step in the predicate DSL allowing the retrieval of a {@link SearchPredicate}. | ||
* @return {@code this}, for method chaining. | ||
*/ | ||
default S filter(PredicateFinalStep dslFinalStep) { | ||
return filter( dslFinalStep.toPredicate() ); | ||
} | ||
|
||
} |
30 changes: 30 additions & 0 deletions
30
.../org/hibernate/search/engine/search/aggregation/dsl/ExtendedSearchAggregationFactory.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,30 @@ | ||
/* | ||
* 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; | ||
|
||
/** | ||
* A base interface for subtypes of {@link SearchAggregationFactory} allowing to | ||
* easily override the predicate factory type for all relevant methods. | ||
* <p> | ||
* <strong>Warning:</strong> Generic parameters of this type are subject to change, | ||
* so this type should not be referenced directtly in user code. | ||
* | ||
* @param <PDF> The type of factory used to create predicates in {@link AggregationFilterStep#filter(Function)}. | ||
*/ | ||
public interface ExtendedSearchAggregationFactory<PDF extends SearchPredicateFactory> | ||
extends SearchAggregationFactory { | ||
|
||
@Override | ||
RangeAggregationFieldStep<PDF> range(); | ||
|
||
@Override | ||
TermsAggregationFieldStep<PDF> terms(); | ||
} |
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
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
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
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
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
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
Oops, something went wrong.