diff --git a/documentation/src/test/java/org/hibernate/search/documentation/search/predicate/FieldReferenceIT.java b/documentation/src/test/java/org/hibernate/search/documentation/search/predicate/FieldReferenceIT.java index b04389673f0..0b5463c227c 100644 --- a/documentation/src/test/java/org/hibernate/search/documentation/search/predicate/FieldReferenceIT.java +++ b/documentation/src/test/java/org/hibernate/search/documentation/search/predicate/FieldReferenceIT.java @@ -67,6 +67,13 @@ void smoke() { .fetchHits( 20 ) ).containsOnly( "c" ); + assertThat( + searchSession.search( EntityC_.scope ) + .select( f -> f.field( EntityC_.stringA ) ) + .where( f -> f.match().field( EntityC_.stringA ).matching( "c" ) ) + .fetchHits( 20 ) + ).containsOnly( "c" ); + SearchScope scope = EntityB_union_EntityC_.scope.create( searchSession ); SearchPredicate searchPredicate = @@ -200,30 +207,24 @@ public static class EntityA_ { } } - public static class EntityB_ { - public static ValueFieldReference1 stringA; + public static class EntityB_ extends EntityA_ { public static ValueFieldReference1 stringB; public static RootReferenceScope scope; static { - stringA = ValueFieldReference1.of( "stringA", EntityB_.class, String.class, String.class, String.class ); stringB = ValueFieldReference1.of( "stringB", EntityB_.class, String.class, String.class, String.class ); scope = RootReferenceScopeImpl.of( EntityB_.class, EntityB.class ); } } - public static class EntityC_ { - public static ValueFieldReference1 stringA; - public static ValueFieldReference1 stringB; + public static class EntityC_ extends EntityB_ { public static ValueFieldReference1 stringC; public static RootReferenceScope scope; static { - stringA = ValueFieldReference1.of( "stringA", EntityC_.class, String.class, String.class, String.class ); - stringB = ValueFieldReference1.of( "stringB", EntityC_.class, String.class, String.class, String.class ); stringC = ValueFieldReference1.of( "stringC", EntityC_.class, String.class, String.class, String.class ); scope = RootReferenceScopeImpl.of( EntityC_.class, EntityC.class ); diff --git a/engine/src/main/java/org/hibernate/search/engine/search/aggregation/dsl/RangeAggregationFieldStep.java b/engine/src/main/java/org/hibernate/search/engine/search/aggregation/dsl/RangeAggregationFieldStep.java index 0b8d8db5fd2..db9403668ee 100644 --- a/engine/src/main/java/org/hibernate/search/engine/search/aggregation/dsl/RangeAggregationFieldStep.java +++ b/engine/src/main/java/org/hibernate/search/engine/search/aggregation/dsl/RangeAggregationFieldStep.java @@ -10,6 +10,7 @@ import org.hibernate.search.engine.search.common.ValueConvert; import org.hibernate.search.engine.search.predicate.dsl.SearchPredicateFactory; +import org.hibernate.search.engine.search.reference.aggregation.RangeAggregationFieldReference; /** * The initial step in a "range" aggregation definition, where the target field can be set. @@ -43,4 +44,15 @@ public interface RangeAggregationFieldStep RangeAggregationRangeStep field(String fieldPath, Class type, ValueConvert convert); + /** + * Target the given field in the range aggregation. + * + * @param fieldReference The field reference representing a path to the index field to aggregate. + * @param The type of field values. + * @return The next step. + */ + default RangeAggregationRangeStep field(RangeAggregationFieldReference fieldReference) { + return field( fieldReference.absolutePath(), fieldReference.aggregationType(), fieldReference.valueConvert() ); + } + } diff --git a/engine/src/main/java/org/hibernate/search/engine/search/aggregation/dsl/SearchAggregationFactory.java b/engine/src/main/java/org/hibernate/search/engine/search/aggregation/dsl/SearchAggregationFactory.java index 4b267811683..44dc6256a3a 100644 --- a/engine/src/main/java/org/hibernate/search/engine/search/aggregation/dsl/SearchAggregationFactory.java +++ b/engine/src/main/java/org/hibernate/search/engine/search/aggregation/dsl/SearchAggregationFactory.java @@ -9,6 +9,7 @@ import java.util.function.Function; import org.hibernate.search.engine.search.common.NamedValues; +import org.hibernate.search.engine.search.reference.object.ObjectFieldReference; import org.hibernate.search.util.common.SearchException; import org.hibernate.search.util.common.annotation.Incubating; @@ -101,6 +102,20 @@ AggregationFinalStep withParameters( @Incubating SearchAggregationFactory withRoot(String objectFieldPath); + /** + * Create a new aggregation factory whose root for all paths passed to the DSL + * will be the given object field. + *

+ * See here for more information. + * + * @param objectFieldReference The reference representing the path from the current root to an object field that will become the new root. + * @return A new aggregation factory using the given object field as root. + */ + @Incubating + default SearchAggregationFactory withRoot(ObjectFieldReference objectFieldReference) { + return withRoot( objectFieldReference.absolutePath() ); + } + /** * @param relativeFieldPath The path to a field, relative to the {@link #withRoot(String) root} of this factory. * @return The absolute path of the field, for use in native aggregations for example. diff --git a/engine/src/main/java/org/hibernate/search/engine/search/aggregation/dsl/TermsAggregationFieldStep.java b/engine/src/main/java/org/hibernate/search/engine/search/aggregation/dsl/TermsAggregationFieldStep.java index cb59e234f6e..679b9b627da 100644 --- a/engine/src/main/java/org/hibernate/search/engine/search/aggregation/dsl/TermsAggregationFieldStep.java +++ b/engine/src/main/java/org/hibernate/search/engine/search/aggregation/dsl/TermsAggregationFieldStep.java @@ -11,6 +11,7 @@ import org.hibernate.search.engine.search.common.ValueConvert; import org.hibernate.search.engine.search.predicate.dsl.SearchPredicateFactory; +import org.hibernate.search.engine.search.reference.aggregation.TermsAggregationFieldReference; /** * The initial step in a "terms" aggregation definition, where the target field can be set. @@ -45,4 +46,16 @@ public interface TermsAggregationFieldStep TermsAggregationOptionsStep> field(String fieldPath, Class type, ValueConvert convert); + /** + * Target the given field in the terms aggregation. + * + * @param fieldReference The field reference representing a path to the index field to aggregate. + * @param The type of field values. + * @return The next step. + */ + default TermsAggregationOptionsStep> field( + TermsAggregationFieldReference fieldReference) { + return field( fieldReference.absolutePath(), fieldReference.aggregationType(), fieldReference.valueConvert() ); + } + } diff --git a/engine/src/main/java/org/hibernate/search/engine/search/predicate/dsl/ExistsPredicateFieldStep.java b/engine/src/main/java/org/hibernate/search/engine/search/predicate/dsl/ExistsPredicateFieldStep.java index 2d6b5f25781..da98925dfb7 100644 --- a/engine/src/main/java/org/hibernate/search/engine/search/predicate/dsl/ExistsPredicateFieldStep.java +++ b/engine/src/main/java/org/hibernate/search/engine/search/predicate/dsl/ExistsPredicateFieldStep.java @@ -33,7 +33,7 @@ public interface ExistsPredicateFieldStep field) { + default N field(ExistsPredicateFieldReference field) { return field( field.absolutePath() ); } diff --git a/engine/src/main/java/org/hibernate/search/engine/search/predicate/dsl/KnnPredicateFieldStep.java b/engine/src/main/java/org/hibernate/search/engine/search/predicate/dsl/KnnPredicateFieldStep.java index 1fb575f893f..49c18b8d65b 100644 --- a/engine/src/main/java/org/hibernate/search/engine/search/predicate/dsl/KnnPredicateFieldStep.java +++ b/engine/src/main/java/org/hibernate/search/engine/search/predicate/dsl/KnnPredicateFieldStep.java @@ -22,5 +22,5 @@ public interface KnnPredicateFieldStep { */ KnnPredicateVectorStep field(String fieldPath); - KnnPredicateVectorGenericStep field(KnnPredicateFieldReference field); + KnnPredicateVectorGenericStep field(KnnPredicateFieldReference field); } diff --git a/engine/src/main/java/org/hibernate/search/engine/search/predicate/dsl/MatchPredicateFieldStep.java b/engine/src/main/java/org/hibernate/search/engine/search/predicate/dsl/MatchPredicateFieldStep.java index a4891b17c45..c33444405bf 100644 --- a/engine/src/main/java/org/hibernate/search/engine/search/predicate/dsl/MatchPredicateFieldStep.java +++ b/engine/src/main/java/org/hibernate/search/engine/search/predicate/dsl/MatchPredicateFieldStep.java @@ -61,8 +61,8 @@ default N field(String fieldPath) { * @return The next step. */ @SuppressWarnings("unchecked") - default MatchPredicateFieldMoreGenericStep> field( - MatchPredicateFieldReference fieldReference) { + default MatchPredicateFieldMoreGenericStep> field( + MatchPredicateFieldReference fieldReference) { return fields( fieldReference ); } @@ -82,6 +82,6 @@ default N field(String fieldPath) { * @see #field(MatchPredicateFieldReference) */ @SuppressWarnings("unchecked") - MatchPredicateFieldMoreGenericStep> fields( - MatchPredicateFieldReference... fieldReferences); + MatchPredicateFieldMoreGenericStep> fields( + MatchPredicateFieldReference... fieldReferences); } diff --git a/engine/src/main/java/org/hibernate/search/engine/search/predicate/dsl/NestedPredicateFieldStep.java b/engine/src/main/java/org/hibernate/search/engine/search/predicate/dsl/NestedPredicateFieldStep.java index 3929d19f801..e6e23ce58fd 100644 --- a/engine/src/main/java/org/hibernate/search/engine/search/predicate/dsl/NestedPredicateFieldStep.java +++ b/engine/src/main/java/org/hibernate/search/engine/search/predicate/dsl/NestedPredicateFieldStep.java @@ -38,7 +38,7 @@ public interface NestedPredicateFieldStep field) { + default N objectField(NestedPredicateFieldReference field) { return objectField( field.absolutePath() ); } diff --git a/engine/src/main/java/org/hibernate/search/engine/search/predicate/dsl/PhrasePredicateFieldMoreStep.java b/engine/src/main/java/org/hibernate/search/engine/search/predicate/dsl/PhrasePredicateFieldMoreStep.java index 890fe7b34a6..d7842df651a 100644 --- a/engine/src/main/java/org/hibernate/search/engine/search/predicate/dsl/PhrasePredicateFieldMoreStep.java +++ b/engine/src/main/java/org/hibernate/search/engine/search/predicate/dsl/PhrasePredicateFieldMoreStep.java @@ -75,7 +75,7 @@ default S field(String fieldPath) { */ @Incubating @SuppressWarnings("unchecked") - default S field(PhrasePredicateFieldReference field) { + default S field(PhrasePredicateFieldReference field) { return fields( field ); } @@ -95,7 +95,7 @@ default S field(PhrasePredicateFieldReference field) { */ @Incubating @SuppressWarnings("unchecked") - default S fields(PhrasePredicateFieldReference... fields) { + default S fields(PhrasePredicateFieldReference... fields) { String[] paths = new String[fields.length]; for ( int i = 0; i < fields.length; i++ ) { paths[i] = fields[i].absolutePath(); diff --git a/engine/src/main/java/org/hibernate/search/engine/search/predicate/dsl/PhrasePredicateFieldStep.java b/engine/src/main/java/org/hibernate/search/engine/search/predicate/dsl/PhrasePredicateFieldStep.java index 67c88a61615..bcb0af49cdb 100644 --- a/engine/src/main/java/org/hibernate/search/engine/search/predicate/dsl/PhrasePredicateFieldStep.java +++ b/engine/src/main/java/org/hibernate/search/engine/search/predicate/dsl/PhrasePredicateFieldStep.java @@ -74,7 +74,7 @@ default N field(String fieldPath) { */ @Incubating @SuppressWarnings("unchecked") - default N field(PhrasePredicateFieldReference field) { + default N field(PhrasePredicateFieldReference field) { return fields( field ); } @@ -97,7 +97,7 @@ default N field(PhrasePredicateFieldReference field) { */ @Incubating @SuppressWarnings("unchecked") - default N fields(PhrasePredicateFieldReference... fields) { + default N fields(PhrasePredicateFieldReference... fields) { String[] paths = new String[fields.length]; for ( int i = 0; i < fields.length; i++ ) { paths[i] = fields[i].absolutePath(); diff --git a/engine/src/main/java/org/hibernate/search/engine/search/predicate/dsl/RangePredicateFieldStep.java b/engine/src/main/java/org/hibernate/search/engine/search/predicate/dsl/RangePredicateFieldStep.java index b79b3b44bb8..9de0f90ed44 100644 --- a/engine/src/main/java/org/hibernate/search/engine/search/predicate/dsl/RangePredicateFieldStep.java +++ b/engine/src/main/java/org/hibernate/search/engine/search/predicate/dsl/RangePredicateFieldStep.java @@ -66,8 +66,8 @@ default N field(String fieldPath) { * @return The next step. */ @SuppressWarnings("unchecked") - default RangePredicateFieldMoreGenericStep, T> field( - RangePredicateFieldReference field) { + default RangePredicateFieldMoreGenericStep, T> field( + RangePredicateFieldReference field) { return fields( field ); } @@ -87,7 +87,7 @@ default N field(String fieldPath) { * @see #field(RangePredicateFieldReference) */ @SuppressWarnings("unchecked") - RangePredicateFieldMoreGenericStep, T> fields( - RangePredicateFieldReference... fields); + RangePredicateFieldMoreGenericStep, T> fields( + RangePredicateFieldReference... fields); } diff --git a/engine/src/main/java/org/hibernate/search/engine/search/predicate/dsl/SearchPredicateFactory.java b/engine/src/main/java/org/hibernate/search/engine/search/predicate/dsl/SearchPredicateFactory.java index 98c7f9f86c5..89691825b80 100644 --- a/engine/src/main/java/org/hibernate/search/engine/search/predicate/dsl/SearchPredicateFactory.java +++ b/engine/src/main/java/org/hibernate/search/engine/search/predicate/dsl/SearchPredicateFactory.java @@ -13,6 +13,7 @@ import org.hibernate.search.engine.search.common.BooleanOperator; import org.hibernate.search.engine.search.common.NamedValues; import org.hibernate.search.engine.search.predicate.SearchPredicate; +import org.hibernate.search.engine.search.reference.object.ObjectFieldReference; import org.hibernate.search.engine.search.reference.predicate.NestedPredicateFieldReference; import org.hibernate.search.util.common.SearchException; import org.hibernate.search.util.common.annotation.Incubating; @@ -248,7 +249,7 @@ SimpleBooleanPredicateOptionsStep or(PredicateFinalStep firstSearchPredicate, * @return The initial step of a DSL where the "nested" predicate can be defined. * @see NestedPredicateFieldStep */ - default NestedPredicateClausesStep nested(NestedPredicateFieldReference field) { + default NestedPredicateClausesStep nested(NestedPredicateFieldReference field) { return nested( field.absolutePath() ); } @@ -369,6 +370,21 @@ PredicateFinalStep withParameters( @Incubating SearchPredicateFactory withRoot(String objectFieldPath); + /** + * Create a new predicate factory whose root for all paths passed to the DSL + * will be the given object field. + *

+ * This is used to call reusable methods that apply the same predicate + * on different object fields that have same structure (same sub-fields). + * + * @param objectFieldReference The reference representing the path from the current root to an object field that will become the new root. + * @return A new predicate factory using the given object field as root. + */ + @Incubating + default SearchPredicateFactory withRoot(ObjectFieldReference objectFieldReference) { + return withRoot( objectFieldReference.absolutePath() ); + } + /** * @param relativeFieldPath The path to a field, relative to the {@link #withRoot(String) root} of this factory. * @return The absolute path of the field, for use in native predicates for example. diff --git a/engine/src/main/java/org/hibernate/search/engine/search/predicate/dsl/impl/AbstractMatchPredicateFieldMoreStep.java b/engine/src/main/java/org/hibernate/search/engine/search/predicate/dsl/impl/AbstractMatchPredicateFieldMoreStep.java index 0aa9023bb80..71f9991ae83 100644 --- a/engine/src/main/java/org/hibernate/search/engine/search/predicate/dsl/impl/AbstractMatchPredicateFieldMoreStep.java +++ b/engine/src/main/java/org/hibernate/search/engine/search/predicate/dsl/impl/AbstractMatchPredicateFieldMoreStep.java @@ -53,11 +53,12 @@ abstract class AbstractMatchPredicateFieldMoreStep< ); } - public static MatchPredicateFieldMoreGenericStep> create( - SearchPredicateDslContext dslContext, MatchPredicateFieldReference[] fields) { + public static MatchPredicateFieldMoreGenericStep> create( + SearchPredicateDslContext dslContext, MatchPredicateFieldReference[] fields) { + List> fieldList = Arrays.asList( fields ); return new MatchPredicateFieldMoreStepFieldReference<>( dslContext, - Arrays.asList( fields ) + fieldList ); } @@ -158,31 +159,32 @@ private static class MatchPredicateFieldMoreStepFieldReference AbstractMatchPredicateFieldMoreStep, MatchPredicateFieldMoreStepFieldReference, T, - MatchPredicateFieldReference> + MatchPredicateFieldReference> implements MatchPredicateFieldMoreGenericStep, MatchPredicateFieldMoreStepFieldReference.CommonState, T, - MatchPredicateFieldReference> { + MatchPredicateFieldReference> { MatchPredicateFieldMoreStepFieldReference(SearchPredicateDslContext dslContext, - List> fieldPaths) { + List> fieldPaths) { super( new CommonState<>( dslContext ), fieldPaths ); } private MatchPredicateFieldMoreStepFieldReference(CommonState commonState, - List> fieldPaths) { + List> fieldPaths) { super( commonState, fieldPaths ); } @Override - public MatchPredicateFieldMoreStepFieldReference field(MatchPredicateFieldReference field) { + public MatchPredicateFieldMoreStepFieldReference field(MatchPredicateFieldReference field) { return new MatchPredicateFieldMoreStepFieldReference<>( commonState, Collections.singletonList( field ) ); } @Override @SuppressWarnings("unchecked") - public MatchPredicateFieldMoreStepFieldReference fields(MatchPredicateFieldReference... fieldPaths) { + public MatchPredicateFieldMoreStepFieldReference fields( + MatchPredicateFieldReference... fieldPaths) { return new MatchPredicateFieldMoreStepFieldReference<>( commonState, Arrays.asList( fieldPaths ) ); } @@ -197,13 +199,15 @@ protected MatchPredicateFieldMoreStepFieldReference thisAsS() { } @Override - protected String fieldPath(MatchPredicateFieldReference field) { + protected String fieldPath(MatchPredicateFieldReference field) { return field.absolutePath(); } private static class CommonState extends - GenericCommonState, MatchPredicateFieldMoreStepFieldReference> { + GenericCommonState, + MatchPredicateFieldMoreStepFieldReference> { CommonState(SearchPredicateDslContext dslContext) { super( dslContext ); } @@ -212,7 +216,7 @@ CommonState matching(T value) { Contracts.assertNotNull( value, "value" ); for ( MatchPredicateFieldMoreStepFieldReference fieldSetState : getFieldSetStates() ) { - for ( Map.Entry, + for ( Map.Entry, MatchPredicateBuilder> entry : fieldSetState.predicateBuilders .entrySet() ) { entry.getValue().value( value, entry.getKey().valueConvert() ); diff --git a/engine/src/main/java/org/hibernate/search/engine/search/predicate/dsl/impl/AbstractRangePredicateFieldMoreStep.java b/engine/src/main/java/org/hibernate/search/engine/search/predicate/dsl/impl/AbstractRangePredicateFieldMoreStep.java index 8b0b2809a59..e9422c3fda8 100644 --- a/engine/src/main/java/org/hibernate/search/engine/search/predicate/dsl/impl/AbstractRangePredicateFieldMoreStep.java +++ b/engine/src/main/java/org/hibernate/search/engine/search/predicate/dsl/impl/AbstractRangePredicateFieldMoreStep.java @@ -59,10 +59,11 @@ public static RangePredicateFieldMoreStepString create( } public static RangePredicateFieldMoreStepReference create( - SearchPredicateDslContext dslContext, RangePredicateFieldReference[] fields) { + SearchPredicateDslContext dslContext, RangePredicateFieldReference[] fields) { + List> fieldsList = Arrays.asList( fields ); return new RangePredicateFieldMoreStepReference<>( dslContext, - Arrays.asList( fields ) + fieldsList ); } @@ -170,26 +171,26 @@ private static class RangePredicateFieldMoreStepReference RangePredicateFieldMoreStepReference.CommonState, RangePredicateFieldMoreStepReference, T, - RangePredicateFieldReference> + RangePredicateFieldReference> implements RangePredicateFieldMoreGenericStep, RangePredicateFieldMoreStepReference.CommonState, - RangePredicateFieldReference, + RangePredicateFieldReference, T> { private RangePredicateFieldMoreStepReference(SearchPredicateDslContext dslContext, - List> fields) { + List> fields) { this( new CommonState<>( dslContext ), fields ); } private RangePredicateFieldMoreStepReference(CommonState commonState, - List> fields) { + List> fields) { super( commonState, fields ); } @Override - protected String fieldPath(RangePredicateFieldReference field) { + protected String fieldPath(RangePredicateFieldReference field) { return field.absolutePath(); } @@ -199,13 +200,13 @@ protected RangePredicateFieldMoreStepReference thisAsS() { } @Override - public RangePredicateFieldMoreStepReference field(RangePredicateFieldReference field) { + public RangePredicateFieldMoreStepReference field(RangePredicateFieldReference field) { return new RangePredicateFieldMoreStepReference<>( commonState, List.of( field ) ); } @Override @SuppressWarnings("unchecked") - public RangePredicateFieldMoreStepReference fields(RangePredicateFieldReference... fields) { + public RangePredicateFieldMoreStepReference fields(RangePredicateFieldReference... fields) { return new RangePredicateFieldMoreStepReference<>( commonState, Arrays.asList( fields ) ); } @@ -217,7 +218,10 @@ public CommonState range(Range range) { public static class CommonState extends - GenericCommonState, RangePredicateFieldMoreStepReference> { + GenericCommonState, + RangePredicateFieldMoreStepReference> { CommonState(SearchPredicateDslContext dslContext) { super( dslContext ); } @@ -238,7 +242,7 @@ CommonState range(Range range) { } @Override - protected String fieldPath(RangePredicateFieldReference field) { + protected String fieldPath(RangePredicateFieldReference field) { return field.absolutePath(); } } diff --git a/engine/src/main/java/org/hibernate/search/engine/search/predicate/dsl/impl/KnnPredicateFieldStepImpl.java b/engine/src/main/java/org/hibernate/search/engine/search/predicate/dsl/impl/KnnPredicateFieldStepImpl.java index 99e2176b5a1..77e41ac6a2e 100644 --- a/engine/src/main/java/org/hibernate/search/engine/search/predicate/dsl/impl/KnnPredicateFieldStepImpl.java +++ b/engine/src/main/java/org/hibernate/search/engine/search/predicate/dsl/impl/KnnPredicateFieldStepImpl.java @@ -45,7 +45,7 @@ public KnnPredicateVectorStep field(String fieldPath) { } @Override - public KnnPredicateVectorGenericStep field(KnnPredicateFieldReference field) { + public KnnPredicateVectorGenericStep field(KnnPredicateFieldReference field) { this.field( field.absolutePath() ); return new KnnPredicateVectorGenericStepImpl<>(); } diff --git a/engine/src/main/java/org/hibernate/search/engine/search/predicate/dsl/impl/MatchPredicateFieldStepImpl.java b/engine/src/main/java/org/hibernate/search/engine/search/predicate/dsl/impl/MatchPredicateFieldStepImpl.java index b639d7f39a9..c0ef8e86039 100644 --- a/engine/src/main/java/org/hibernate/search/engine/search/predicate/dsl/impl/MatchPredicateFieldStepImpl.java +++ b/engine/src/main/java/org/hibernate/search/engine/search/predicate/dsl/impl/MatchPredicateFieldStepImpl.java @@ -27,8 +27,8 @@ public MatchPredicateFieldStepImpl(SearchPredicateDslContext dslContext) { @Override @SuppressWarnings("unchecked") - public MatchPredicateFieldMoreGenericStep> fields( - MatchPredicateFieldReference... fields) { + public MatchPredicateFieldMoreGenericStep> fields( + MatchPredicateFieldReference... fields) { return AbstractMatchPredicateFieldMoreStep.create( dslContext, fields ); } } diff --git a/engine/src/main/java/org/hibernate/search/engine/search/predicate/dsl/impl/RangePredicateFieldStepImpl.java b/engine/src/main/java/org/hibernate/search/engine/search/predicate/dsl/impl/RangePredicateFieldStepImpl.java index 0077c5d4fee..01685b3f760 100644 --- a/engine/src/main/java/org/hibernate/search/engine/search/predicate/dsl/impl/RangePredicateFieldStepImpl.java +++ b/engine/src/main/java/org/hibernate/search/engine/search/predicate/dsl/impl/RangePredicateFieldStepImpl.java @@ -29,8 +29,8 @@ public RangePredicateFieldStepImpl(SearchPredicateDslContext dslContext) { @Override @SuppressWarnings("unchecked") - public RangePredicateFieldMoreGenericStep, T> fields( - RangePredicateFieldReference... fields) { + public RangePredicateFieldMoreGenericStep, T> fields( + RangePredicateFieldReference... fields) { return AbstractRangePredicateFieldMoreStep.create( dslContext, fields ); } diff --git a/engine/src/main/java/org/hibernate/search/engine/search/projection/dsl/ExtendedSearchProjectionFactory.java b/engine/src/main/java/org/hibernate/search/engine/search/projection/dsl/ExtendedSearchProjectionFactory.java index cadffde67bb..9c117007400 100644 --- a/engine/src/main/java/org/hibernate/search/engine/search/projection/dsl/ExtendedSearchProjectionFactory.java +++ b/engine/src/main/java/org/hibernate/search/engine/search/projection/dsl/ExtendedSearchProjectionFactory.java @@ -26,7 +26,7 @@ public interface ExtendedSearchProjectionFactory objectFieldReference) { + default S withRoot(ObjectFieldReference objectFieldReference) { return withRoot( objectFieldReference.absolutePath() ); } } diff --git a/engine/src/main/java/org/hibernate/search/engine/search/projection/dsl/SearchProjectionFactory.java b/engine/src/main/java/org/hibernate/search/engine/search/projection/dsl/SearchProjectionFactory.java index c6de7b5fa5e..8e87ab208df 100644 --- a/engine/src/main/java/org/hibernate/search/engine/search/projection/dsl/SearchProjectionFactory.java +++ b/engine/src/main/java/org/hibernate/search/engine/search/projection/dsl/SearchProjectionFactory.java @@ -173,7 +173,7 @@ default FieldProjectionValueStep field(String fieldPath) { * @return A DSL step where the "field" projection can be defined in more details. */ @Incubating - default FieldProjectionValueStep field(FieldProjectionFieldReference fieldReference) { + default FieldProjectionValueStep field(FieldProjectionFieldReference fieldReference) { return field( fieldReference.absolutePath(), fieldReference.projectionType(), fieldReference.valueConvert() ); } @@ -203,7 +203,8 @@ default FieldProjectionValueStep field(FieldProjectionFieldReference distance(DistanceProjectionFieldReference fieldReference, + default DistanceToFieldProjectionValueStep distance( + DistanceProjectionFieldReference fieldReference, GeoPoint center) { return distance( fieldReference.absolutePath(), center ); } @@ -241,7 +242,7 @@ default DistanceToFieldProjectionValueStep distance(DistanceProjectio * @return A DSL step where the "composite" projection can be defined in more details. */ @Incubating - default CompositeProjectionInnerStep object(ObjectFieldReference objectFieldReference) { + default CompositeProjectionInnerStep object(ObjectFieldReference objectFieldReference) { return object( objectFieldReference.absolutePath() ); } @@ -500,7 +501,7 @@ ProjectionFinalStep withParameters( * @return A new projection factory using the given object field as root. */ @Incubating - default SearchProjectionFactory withRoot(ObjectFieldReference objectFieldReference) { + default SearchProjectionFactory withRoot(ObjectFieldReference objectFieldReference) { return withRoot( objectFieldReference.absolutePath() ); } @@ -528,7 +529,7 @@ default SearchProjectionFactory withRoot(ObjectFieldReference obje * @return A DSL step where the "highlight" projection can be defined in more details. */ @Incubating - default HighlightProjectionOptionsStep highlight(HighlightProjectionFieldReference fieldReference) { + default HighlightProjectionOptionsStep highlight(HighlightProjectionFieldReference fieldReference) { return highlight( fieldReference.absolutePath() ); } } diff --git a/engine/src/main/java/org/hibernate/search/engine/search/sort/dsl/ExtendedSearchSortFactory.java b/engine/src/main/java/org/hibernate/search/engine/search/sort/dsl/ExtendedSearchSortFactory.java index baabf839fcd..309957e6f76 100644 --- a/engine/src/main/java/org/hibernate/search/engine/search/sort/dsl/ExtendedSearchSortFactory.java +++ b/engine/src/main/java/org/hibernate/search/engine/search/sort/dsl/ExtendedSearchSortFactory.java @@ -34,7 +34,7 @@ public interface ExtendedSearchSortFactory< S withRoot(String objectFieldPath); @Override - default S withRoot(ObjectFieldReference objectFieldReference) { + default S withRoot(ObjectFieldReference objectFieldReference) { return withRoot( objectFieldReference.absolutePath() ); } @@ -50,12 +50,13 @@ default S withRoot(ObjectFieldReference objectFieldReference) { } @Override - default DistanceSortOptionsStep distance(FieldSortFieldReference fieldReference, GeoPoint location) { + default DistanceSortOptionsStep distance(FieldSortFieldReference fieldReference, + GeoPoint location) { return distance( fieldReference.absolutePath(), location ); } @Override - default DistanceSortOptionsStep distance(FieldSortFieldReference fieldReference, double latitude, + default DistanceSortOptionsStep distance(FieldSortFieldReference fieldReference, double latitude, double longitude) { return distance( fieldReference, GeoPoint.of( latitude, longitude ) ); } diff --git a/engine/src/main/java/org/hibernate/search/engine/search/sort/dsl/SearchSortFactory.java b/engine/src/main/java/org/hibernate/search/engine/search/sort/dsl/SearchSortFactory.java index dffe67d9e69..041b534faec 100644 --- a/engine/src/main/java/org/hibernate/search/engine/search/sort/dsl/SearchSortFactory.java +++ b/engine/src/main/java/org/hibernate/search/engine/search/sort/dsl/SearchSortFactory.java @@ -77,7 +77,7 @@ public interface SearchSortFactory { */ @Incubating FieldSortOptionsGenericStep> field( - FieldSortFieldReference fieldReference); + FieldSortFieldReference fieldReference); /** * Order elements by the distance from the location stored in the specified field to the location specified. @@ -105,7 +105,7 @@ public interface SearchSortFactory { */ @Incubating default DistanceSortOptionsStep> distance( - FieldSortFieldReference fieldReference, GeoPoint location) { + FieldSortFieldReference fieldReference, GeoPoint location) { return distance( fieldReference.absolutePath(), location ); } @@ -140,7 +140,7 @@ public interface SearchSortFactory { */ @Incubating default DistanceSortOptionsStep> distance( - FieldSortFieldReference fieldReference, double latitude, + FieldSortFieldReference fieldReference, double latitude, double longitude) { return distance( fieldReference, GeoPoint.of( latitude, longitude ) ); } @@ -237,7 +237,7 @@ public interface SearchSortFactory { * @return A new sort factory using the given object field as root. */ @Incubating - default SearchSortFactory withRoot(ObjectFieldReference objectFieldReference) { + default SearchSortFactory withRoot(ObjectFieldReference objectFieldReference) { return withRoot( objectFieldReference.absolutePath() ); } diff --git a/engine/src/main/java/org/hibernate/search/engine/search/sort/dsl/impl/FieldSortOptionsGenericStepImpl.java b/engine/src/main/java/org/hibernate/search/engine/search/sort/dsl/impl/FieldSortOptionsGenericStepImpl.java index 5821280ddcb..85d7d9269b4 100644 --- a/engine/src/main/java/org/hibernate/search/engine/search/sort/dsl/impl/FieldSortOptionsGenericStepImpl.java +++ b/engine/src/main/java/org/hibernate/search/engine/search/sort/dsl/impl/FieldSortOptionsGenericStepImpl.java @@ -38,7 +38,7 @@ public class FieldSortOptionsGenericStepImpl dslContext, - FieldSortFieldReference fieldReference) { + FieldSortFieldReference fieldReference) { super( dslContext ); this.dslContext = dslContext; this.builder = dslContext.scope().fieldQueryElement( fieldReference.absolutePath(), SortTypeKeys.FIELD ); diff --git a/engine/src/main/java/org/hibernate/search/engine/search/sort/dsl/spi/AbstractSearchSortFactory.java b/engine/src/main/java/org/hibernate/search/engine/search/sort/dsl/spi/AbstractSearchSortFactory.java index a7d3714f7da..90b3e258407 100644 --- a/engine/src/main/java/org/hibernate/search/engine/search/sort/dsl/spi/AbstractSearchSortFactory.java +++ b/engine/src/main/java/org/hibernate/search/engine/search/sort/dsl/spi/AbstractSearchSortFactory.java @@ -64,7 +64,7 @@ public SortThenStep indexOrder() { @Override public FieldSortOptionsGenericStep> field( - FieldSortFieldReference fieldReference) { + FieldSortFieldReference fieldReference) { return new FieldSortOptionsGenericStepImpl<>( dslContext, fieldReference ); }