From cbfcec9d0e1119382c1c8f788461095a763c302f Mon Sep 17 00:00:00 2001 From: marko-bekhta Date: Thu, 12 Dec 2024 22:26:08 +0100 Subject: [PATCH] HSEARCH-3319 Address scope changes in the Lucene - next backend --- .../backend/lucene/LuceneExtension.java | 41 ++++++++++--------- .../impl/LuceneSearchIndexScopeImpl.java | 14 +++---- .../dsl/LuceneSearchAggregationFactory.java | 4 +- .../LuceneSearchAggregationFactoryImpl.java | 17 ++++---- .../dsl/LuceneSearchPredicateFactory.java | 2 +- .../LuceneSearchPredicateFactoryImpl.java | 11 ++--- .../predicate/impl/LuceneNamedPredicate.java | 9 ++-- .../dsl/LuceneSearchProjectionFactory.java | 5 ++- .../LuceneSearchProjectionFactoryImpl.java | 9 ++-- .../dsl/LuceneSearchQueryOptionsStep.java | 9 ++-- .../dsl/LuceneSearchQuerySelectStep.java | 25 +++++------ .../query/dsl/LuceneSearchQueryWhereStep.java | 4 +- .../LuceneSearchQueryOptionsStepImpl.java | 21 +++++----- .../impl/LuceneSearchQuerySelectStepImpl.java | 39 +++++++++--------- .../impl/LuceneSearchQueryIndexScope.java | 8 ++-- .../sort/dsl/LuceneSearchSortFactory.java | 8 ++-- .../dsl/impl/LuceneSearchSortFactoryImpl.java | 19 +++++---- 17 files changed, 129 insertions(+), 116 deletions(-) diff --git a/lucene-next/backend/lucene/src/main/java/org/hibernate/search/backend/lucene/LuceneExtension.java b/lucene-next/backend/lucene/src/main/java/org/hibernate/search/backend/lucene/LuceneExtension.java index 179f112a40f..43a4eb1fecb 100644 --- a/lucene-next/backend/lucene/src/main/java/org/hibernate/search/backend/lucene/LuceneExtension.java +++ b/lucene-next/backend/lucene/src/main/java/org/hibernate/search/backend/lucene/LuceneExtension.java @@ -63,22 +63,23 @@ * * @see #get() */ -public final class LuceneExtension - implements SearchQueryDslExtension, R, E, LOS>, +public final class LuceneExtension + implements SearchQueryDslExtension, R, E, LOS>, SearchQueryExtension, H>, - SearchPredicateFactoryExtension, - SearchSortFactoryExtension, - SearchProjectionFactoryExtension, R, E>, - SearchAggregationFactoryExtension, + SearchPredicateFactoryExtension>, + SearchSortFactoryExtension>, + SearchProjectionFactoryExtension, R, E>, + SearchAggregationFactoryExtension>, IndexFieldTypeFactoryExtension, IndexScopeExtension, SchemaExportExtension { - private static final LuceneExtension INSTANCE = new LuceneExtension<>(); + private static final LuceneExtension INSTANCE = new LuceneExtension<>(); /** * Get the extension with generic parameters automatically set as appropriate for the context in which it's used. * + * @param Scope root type. * @param The type of query hits. * Users should not have to care about this, as the parameter will automatically take the appropriate value when calling * {@code .extension( LuceneExtension.get() }. @@ -94,8 +95,8 @@ public final class LuceneExtension * @return The extension. */ @SuppressWarnings("unchecked") // The instance works for any H, R and E - public static LuceneExtension get() { - return (LuceneExtension) INSTANCE; + public static LuceneExtension get() { + return (LuceneExtension) INSTANCE; } private LuceneExtension() { @@ -106,8 +107,8 @@ private LuceneExtension() { * {@inheritDoc} */ @Override - public Optional> extendOptional( - SearchQuerySelectStep original, + public Optional> extendOptional( + SearchQuerySelectStep original, SearchQueryIndexScope scope, BackendSessionContext sessionContext, SearchLoadingContextBuilder loadingContextBuilder) { @@ -139,9 +140,9 @@ public Optional> extendOptional(SearchQuery original, * {@inheritDoc} */ @Override - public Optional extendOptional(SearchPredicateFactory original) { + public Optional> extendOptional(SearchPredicateFactory original) { if ( original instanceof LuceneSearchPredicateFactory ) { - return Optional.of( (LuceneSearchPredicateFactory) original ); + return Optional.of( (LuceneSearchPredicateFactory) original ); } else { return Optional.empty(); @@ -152,10 +153,10 @@ public Optional extendOptional(SearchPredicateFact * {@inheritDoc} */ @Override - public Optional extendOptional( - SearchSortFactory original) { + public Optional> extendOptional( + SearchSortFactory original) { if ( original instanceof LuceneSearchSortFactory ) { - return Optional.of( (LuceneSearchSortFactory) original ); + return Optional.of( (LuceneSearchSortFactory) original ); } else { return Optional.empty(); @@ -166,9 +167,9 @@ public Optional extendOptional( * {@inheritDoc} */ @Override - public Optional> extendOptional(SearchProjectionFactory original) { + public Optional> extendOptional(SearchProjectionFactory original) { if ( original instanceof LuceneSearchProjectionFactory ) { - return Optional.of( (LuceneSearchProjectionFactory) original ); + return Optional.of( (LuceneSearchProjectionFactory) original ); } else { return Optional.empty(); @@ -179,9 +180,9 @@ public Optional> extendOptional(SearchProjec * {@inheritDoc} */ @Override - public Optional extendOptional(SearchAggregationFactory original) { + public Optional> extendOptional(SearchAggregationFactory original) { if ( original instanceof LuceneSearchAggregationFactory ) { - return Optional.of( (LuceneSearchAggregationFactory) original ); + return Optional.of( (LuceneSearchAggregationFactory) original ); } else { return Optional.empty(); diff --git a/lucene-next/backend/lucene/src/main/java/org/hibernate/search/backend/lucene/scope/model/impl/LuceneSearchIndexScopeImpl.java b/lucene-next/backend/lucene/src/main/java/org/hibernate/search/backend/lucene/scope/model/impl/LuceneSearchIndexScopeImpl.java index 08770115084..e0e1b54c943 100644 --- a/lucene-next/backend/lucene/src/main/java/org/hibernate/search/backend/lucene/scope/model/impl/LuceneSearchIndexScopeImpl.java +++ b/lucene-next/backend/lucene/src/main/java/org/hibernate/search/backend/lucene/scope/model/impl/LuceneSearchIndexScopeImpl.java @@ -162,24 +162,24 @@ public

LuceneSearchQueryBuilder

select(BackendSessionContext sessionConte } @Override - public LuceneSearchPredicateFactory predicateFactory() { - return new LuceneSearchPredicateFactoryImpl( SearchPredicateDslContext.root( this ) ); + public LuceneSearchPredicateFactory predicateFactory() { + return new LuceneSearchPredicateFactoryImpl<>( SearchPredicateDslContext.root( this ) ); } @Override - public LuceneSearchSortFactory sortFactory() { - return new LuceneSearchSortFactoryImpl( SearchSortDslContext + public LuceneSearchSortFactory sortFactory() { + return new LuceneSearchSortFactoryImpl( SearchSortDslContext .root( this, LuceneSearchSortFactoryImpl::new, predicateFactory() ) ); } @Override - public LuceneSearchProjectionFactory projectionFactory() { + public LuceneSearchProjectionFactory projectionFactory() { return new LuceneSearchProjectionFactoryImpl<>( SearchProjectionDslContext.root( this ) ); } @Override - public LuceneSearchAggregationFactory aggregationFactory() { - return new LuceneSearchAggregationFactoryImpl( SearchAggregationDslContext.root( this, predicateFactory() ) ); + public LuceneSearchAggregationFactory aggregationFactory() { + return new LuceneSearchAggregationFactoryImpl( SearchAggregationDslContext.root( this, predicateFactory() ) ); } @Override diff --git a/lucene-next/backend/lucene/src/main/java/org/hibernate/search/backend/lucene/search/aggregation/dsl/LuceneSearchAggregationFactory.java b/lucene-next/backend/lucene/src/main/java/org/hibernate/search/backend/lucene/search/aggregation/dsl/LuceneSearchAggregationFactory.java index 672d8055ef7..3d7ab6f90bb 100644 --- a/lucene-next/backend/lucene/src/main/java/org/hibernate/search/backend/lucene/search/aggregation/dsl/LuceneSearchAggregationFactory.java +++ b/lucene-next/backend/lucene/src/main/java/org/hibernate/search/backend/lucene/search/aggregation/dsl/LuceneSearchAggregationFactory.java @@ -7,7 +7,7 @@ import org.hibernate.search.backend.lucene.search.predicate.dsl.LuceneSearchPredicateFactory; import org.hibernate.search.engine.search.aggregation.dsl.ExtendedSearchAggregationFactory; -public interface LuceneSearchAggregationFactory - extends ExtendedSearchAggregationFactory { +public interface LuceneSearchAggregationFactory + extends ExtendedSearchAggregationFactory, LuceneSearchPredicateFactory> { } diff --git a/lucene-next/backend/lucene/src/main/java/org/hibernate/search/backend/lucene/search/aggregation/dsl/impl/LuceneSearchAggregationFactoryImpl.java b/lucene-next/backend/lucene/src/main/java/org/hibernate/search/backend/lucene/search/aggregation/dsl/impl/LuceneSearchAggregationFactoryImpl.java index 88f7d780848..b22685c68a8 100644 --- a/lucene-next/backend/lucene/src/main/java/org/hibernate/search/backend/lucene/search/aggregation/dsl/impl/LuceneSearchAggregationFactoryImpl.java +++ b/lucene-next/backend/lucene/src/main/java/org/hibernate/search/backend/lucene/search/aggregation/dsl/impl/LuceneSearchAggregationFactoryImpl.java @@ -10,21 +10,24 @@ import org.hibernate.search.engine.search.aggregation.dsl.spi.AbstractSearchAggregationFactory; import org.hibernate.search.engine.search.aggregation.dsl.spi.SearchAggregationDslContext; -public class LuceneSearchAggregationFactoryImpl +public class LuceneSearchAggregationFactoryImpl extends AbstractSearchAggregationFactory< - LuceneSearchAggregationFactory, + SR, + LuceneSearchAggregationFactory, LuceneSearchAggregationIndexScope, - LuceneSearchPredicateFactory> - implements LuceneSearchAggregationFactory { + LuceneSearchPredicateFactory> + implements LuceneSearchAggregationFactory { public LuceneSearchAggregationFactoryImpl( - SearchAggregationDslContext, LuceneSearchPredicateFactory> dslContext) { + SearchAggregationDslContext, + LuceneSearchPredicateFactory> dslContext) { super( dslContext ); } @Override - public LuceneSearchAggregationFactory withRoot(String objectFieldPath) { - return new LuceneSearchAggregationFactoryImpl( dslContext.rescope( + public LuceneSearchAggregationFactory withRoot(String objectFieldPath) { + return new LuceneSearchAggregationFactoryImpl( dslContext.rescope( dslContext.scope().withRoot( objectFieldPath ), dslContext.predicateFactory().withRoot( objectFieldPath ) ) ); } diff --git a/lucene-next/backend/lucene/src/main/java/org/hibernate/search/backend/lucene/search/predicate/dsl/LuceneSearchPredicateFactory.java b/lucene-next/backend/lucene/src/main/java/org/hibernate/search/backend/lucene/search/predicate/dsl/LuceneSearchPredicateFactory.java index 5bfdfc80fad..9fc4d5f8c77 100644 --- a/lucene-next/backend/lucene/src/main/java/org/hibernate/search/backend/lucene/search/predicate/dsl/LuceneSearchPredicateFactory.java +++ b/lucene-next/backend/lucene/src/main/java/org/hibernate/search/backend/lucene/search/predicate/dsl/LuceneSearchPredicateFactory.java @@ -12,7 +12,7 @@ /** * A factory for search predicates with some Lucene-specific methods. */ -public interface LuceneSearchPredicateFactory extends ExtendedSearchPredicateFactory { +public interface LuceneSearchPredicateFactory extends ExtendedSearchPredicateFactory> { /** * Create a predicate from a Lucene {@link Query}. diff --git a/lucene-next/backend/lucene/src/main/java/org/hibernate/search/backend/lucene/search/predicate/dsl/impl/LuceneSearchPredicateFactoryImpl.java b/lucene-next/backend/lucene/src/main/java/org/hibernate/search/backend/lucene/search/predicate/dsl/impl/LuceneSearchPredicateFactoryImpl.java index 121daec55d3..bb73666ba1b 100644 --- a/lucene-next/backend/lucene/src/main/java/org/hibernate/search/backend/lucene/search/predicate/dsl/impl/LuceneSearchPredicateFactoryImpl.java +++ b/lucene-next/backend/lucene/src/main/java/org/hibernate/search/backend/lucene/search/predicate/dsl/impl/LuceneSearchPredicateFactoryImpl.java @@ -13,19 +13,20 @@ import org.apache.lucene.search.Query; -public class LuceneSearchPredicateFactoryImpl +public class LuceneSearchPredicateFactoryImpl extends AbstractSearchPredicateFactory< - LuceneSearchPredicateFactory, + SR, + LuceneSearchPredicateFactory, LuceneSearchPredicateIndexScope> - implements LuceneSearchPredicateFactory { + implements LuceneSearchPredicateFactory { public LuceneSearchPredicateFactoryImpl(SearchPredicateDslContext> dslContext) { super( dslContext ); } @Override - public LuceneSearchPredicateFactory withRoot(String objectFieldPath) { - return new LuceneSearchPredicateFactoryImpl( dslContext.rescope( + public LuceneSearchPredicateFactory withRoot(String objectFieldPath) { + return new LuceneSearchPredicateFactoryImpl( dslContext.rescope( dslContext.scope().withRoot( objectFieldPath ) ) ); } diff --git a/lucene-next/backend/lucene/src/main/java/org/hibernate/search/backend/lucene/search/predicate/impl/LuceneNamedPredicate.java b/lucene-next/backend/lucene/src/main/java/org/hibernate/search/backend/lucene/search/predicate/impl/LuceneNamedPredicate.java index 789c1fb1b3e..8da0453254e 100644 --- a/lucene-next/backend/lucene/src/main/java/org/hibernate/search/backend/lucene/search/predicate/impl/LuceneNamedPredicate.java +++ b/lucene-next/backend/lucene/src/main/java/org/hibernate/search/backend/lucene/search/predicate/impl/LuceneNamedPredicate.java @@ -70,7 +70,7 @@ private static class Builder extends AbstractBuilder implements NamedPredicateBu private final PredicateDefinition definition; private final String predicateName; private final LuceneSearchIndexCompositeNodeContext field; - private SearchPredicateFactory factory; + private SearchPredicateFactory factory; private final Map params = new LinkedHashMap<>(); Builder(PredicateDefinition definition, String predicateName, LuceneSearchIndexScope scope, @@ -82,7 +82,7 @@ private static class Builder extends AbstractBuilder implements NamedPredicateBu } @Override - public void factory(SearchPredicateFactory factory) { + public void factory(SearchPredicateFactory factory) { this.factory = factory; } @@ -93,8 +93,9 @@ public void param(String name, Object value) { @Override public SearchPredicate build() { - NamedValuesBasedPredicateDefinitionContext ctx = new NamedValuesBasedPredicateDefinitionContext( factory, params, - name -> QueryLog.INSTANCE.paramNotDefined( name, predicateName, field.eventContext() ) ); + NamedValuesBasedPredicateDefinitionContext ctx = + new NamedValuesBasedPredicateDefinitionContext<>( factory, params, + name -> QueryLog.INSTANCE.paramNotDefined( name, predicateName, field.eventContext() ) ); LuceneSearchPredicate providedPredicate = LuceneSearchPredicate.from( scope, definition.create( ctx ) ); diff --git a/lucene-next/backend/lucene/src/main/java/org/hibernate/search/backend/lucene/search/projection/dsl/LuceneSearchProjectionFactory.java b/lucene-next/backend/lucene/src/main/java/org/hibernate/search/backend/lucene/search/projection/dsl/LuceneSearchProjectionFactory.java index abf30741110..94d8717e4c0 100644 --- a/lucene-next/backend/lucene/src/main/java/org/hibernate/search/backend/lucene/search/projection/dsl/LuceneSearchProjectionFactory.java +++ b/lucene-next/backend/lucene/src/main/java/org/hibernate/search/backend/lucene/search/projection/dsl/LuceneSearchProjectionFactory.java @@ -15,12 +15,13 @@ /** * A factory for search projections with some Lucene-specific methods. * + * @param Scope root type. * @param The type of entity references. * @param The type of entities. * @see SearchProjectionFactory */ -public interface LuceneSearchProjectionFactory - extends ExtendedSearchProjectionFactory, R, E> { +public interface LuceneSearchProjectionFactory + extends ExtendedSearchProjectionFactory, R, E> { /** * Project to a Lucene {@link Document} containing all the stored fields. diff --git a/lucene-next/backend/lucene/src/main/java/org/hibernate/search/backend/lucene/search/projection/dsl/impl/LuceneSearchProjectionFactoryImpl.java b/lucene-next/backend/lucene/src/main/java/org/hibernate/search/backend/lucene/search/projection/dsl/impl/LuceneSearchProjectionFactoryImpl.java index daf4eb4bfdd..8b1d8c2d554 100644 --- a/lucene-next/backend/lucene/src/main/java/org/hibernate/search/backend/lucene/search/projection/dsl/impl/LuceneSearchProjectionFactoryImpl.java +++ b/lucene-next/backend/lucene/src/main/java/org/hibernate/search/backend/lucene/search/projection/dsl/impl/LuceneSearchProjectionFactoryImpl.java @@ -15,20 +15,21 @@ import org.apache.lucene.document.Document; import org.apache.lucene.search.Explanation; -public class LuceneSearchProjectionFactoryImpl +public class LuceneSearchProjectionFactoryImpl extends AbstractSearchProjectionFactory< - LuceneSearchProjectionFactory, + SR, + LuceneSearchProjectionFactory, LuceneSearchProjectionIndexScope, R, E> - implements LuceneSearchProjectionFactory { + implements LuceneSearchProjectionFactory { public LuceneSearchProjectionFactoryImpl(SearchProjectionDslContext> dslContext) { super( dslContext ); } @Override - public LuceneSearchProjectionFactory withRoot(String objectFieldPath) { + public LuceneSearchProjectionFactory withRoot(String objectFieldPath) { return new LuceneSearchProjectionFactoryImpl<>( dslContext.rescope( dslContext.scope().withRoot( objectFieldPath ) ) ); } diff --git a/lucene-next/backend/lucene/src/main/java/org/hibernate/search/backend/lucene/search/query/dsl/LuceneSearchQueryOptionsStep.java b/lucene-next/backend/lucene/src/main/java/org/hibernate/search/backend/lucene/search/query/dsl/LuceneSearchQueryOptionsStep.java index fca7d25b2f6..df0f94d6d2d 100644 --- a/lucene-next/backend/lucene/src/main/java/org/hibernate/search/backend/lucene/search/query/dsl/LuceneSearchQueryOptionsStep.java +++ b/lucene-next/backend/lucene/src/main/java/org/hibernate/search/backend/lucene/search/query/dsl/LuceneSearchQueryOptionsStep.java @@ -10,13 +10,14 @@ import org.hibernate.search.backend.lucene.search.sort.dsl.LuceneSearchSortFactory; import org.hibernate.search.engine.search.query.dsl.SearchQueryOptionsStep; -public interface LuceneSearchQueryOptionsStep +public interface LuceneSearchQueryOptionsStep extends SearchQueryOptionsStep< - LuceneSearchQueryOptionsStep, + SR, + LuceneSearchQueryOptionsStep, H, LOS, - LuceneSearchSortFactory, - LuceneSearchAggregationFactory>, + LuceneSearchSortFactory, + LuceneSearchAggregationFactory>, LuceneSearchFetchable { @Override diff --git a/lucene-next/backend/lucene/src/main/java/org/hibernate/search/backend/lucene/search/query/dsl/LuceneSearchQuerySelectStep.java b/lucene-next/backend/lucene/src/main/java/org/hibernate/search/backend/lucene/search/query/dsl/LuceneSearchQuerySelectStep.java index 0c64a658dd4..44d180ae731 100644 --- a/lucene-next/backend/lucene/src/main/java/org/hibernate/search/backend/lucene/search/query/dsl/LuceneSearchQuerySelectStep.java +++ b/lucene-next/backend/lucene/src/main/java/org/hibernate/search/backend/lucene/search/query/dsl/LuceneSearchQuerySelectStep.java @@ -13,33 +13,34 @@ import org.hibernate.search.engine.search.projection.dsl.ProjectionFinalStep; import org.hibernate.search.engine.search.query.dsl.SearchQuerySelectStep; -public interface LuceneSearchQuerySelectStep +public interface LuceneSearchQuerySelectStep extends SearchQuerySelectStep< - LuceneSearchQueryOptionsStep, + SR, + LuceneSearchQueryOptionsStep, R, E, LOS, - LuceneSearchProjectionFactory, - LuceneSearchPredicateFactory>, - LuceneSearchQueryWhereStep { + LuceneSearchProjectionFactory, + LuceneSearchPredicateFactory>, + LuceneSearchQueryWhereStep { @Override - LuceneSearchQueryWhereStep selectEntity(); + LuceneSearchQueryWhereStep selectEntity(); @Override - LuceneSearchQueryWhereStep selectEntityReference(); + LuceneSearchQueryWhereStep selectEntityReference(); @Override -

LuceneSearchQueryWhereStep select(Class

objectClass); +

LuceneSearchQueryWhereStep select(Class

objectClass); @Override -

LuceneSearchQueryWhereStep select( - Function, ? extends ProjectionFinalStep

> projectionContributor); +

LuceneSearchQueryWhereStep select( + Function, ? extends ProjectionFinalStep

> projectionContributor); @Override -

LuceneSearchQueryWhereStep select(SearchProjection

projection); +

LuceneSearchQueryWhereStep select(SearchProjection

projection); @Override - LuceneSearchQueryWhereStep, LOS> select(SearchProjection... projections); + LuceneSearchQueryWhereStep, LOS> select(SearchProjection... projections); } diff --git a/lucene-next/backend/lucene/src/main/java/org/hibernate/search/backend/lucene/search/query/dsl/LuceneSearchQueryWhereStep.java b/lucene-next/backend/lucene/src/main/java/org/hibernate/search/backend/lucene/search/query/dsl/LuceneSearchQueryWhereStep.java index 04aa09d4e43..cfe93fdeb8c 100644 --- a/lucene-next/backend/lucene/src/main/java/org/hibernate/search/backend/lucene/search/query/dsl/LuceneSearchQueryWhereStep.java +++ b/lucene-next/backend/lucene/src/main/java/org/hibernate/search/backend/lucene/search/query/dsl/LuceneSearchQueryWhereStep.java @@ -7,7 +7,7 @@ import org.hibernate.search.backend.lucene.search.predicate.dsl.LuceneSearchPredicateFactory; import org.hibernate.search.engine.search.query.dsl.SearchQueryWhereStep; -public interface LuceneSearchQueryWhereStep - extends SearchQueryWhereStep, H, LOS, LuceneSearchPredicateFactory> { +public interface LuceneSearchQueryWhereStep + extends SearchQueryWhereStep, H, LOS, LuceneSearchPredicateFactory> { } diff --git a/lucene-next/backend/lucene/src/main/java/org/hibernate/search/backend/lucene/search/query/dsl/impl/LuceneSearchQueryOptionsStepImpl.java b/lucene-next/backend/lucene/src/main/java/org/hibernate/search/backend/lucene/search/query/dsl/impl/LuceneSearchQueryOptionsStepImpl.java index b7eec76fa5e..3515b979882 100644 --- a/lucene-next/backend/lucene/src/main/java/org/hibernate/search/backend/lucene/search/query/dsl/impl/LuceneSearchQueryOptionsStepImpl.java +++ b/lucene-next/backend/lucene/src/main/java/org/hibernate/search/backend/lucene/search/query/dsl/impl/LuceneSearchQueryOptionsStepImpl.java @@ -18,18 +18,19 @@ import org.hibernate.search.engine.search.loading.spi.SearchLoadingContextBuilder; import org.hibernate.search.engine.search.query.dsl.spi.AbstractExtendedSearchQueryOptionsStep; -class LuceneSearchQueryOptionsStepImpl +class LuceneSearchQueryOptionsStepImpl extends AbstractExtendedSearchQueryOptionsStep< - LuceneSearchQueryOptionsStep, + SR, + LuceneSearchQueryOptionsStep, H, LuceneSearchResult, LuceneSearchScroll, LOS, - LuceneSearchPredicateFactory, - LuceneSearchSortFactory, - LuceneSearchAggregationFactory, + LuceneSearchPredicateFactory, + LuceneSearchSortFactory, + LuceneSearchAggregationFactory, LuceneSearchQueryIndexScope> - implements LuceneSearchQueryWhereStep, LuceneSearchQueryOptionsStep { + implements LuceneSearchQueryWhereStep, LuceneSearchQueryOptionsStep { private final LuceneSearchQueryBuilder searchQueryBuilder; @@ -46,22 +47,22 @@ public LuceneSearchQuery toQuery() { } @Override - protected LuceneSearchQueryOptionsStepImpl thisAsS() { + protected LuceneSearchQueryOptionsStepImpl thisAsS() { return this; } @Override - protected LuceneSearchPredicateFactory predicateFactory() { + protected LuceneSearchPredicateFactory predicateFactory() { return scope.predicateFactory(); } @Override - protected LuceneSearchSortFactory sortFactory() { + protected LuceneSearchSortFactory sortFactory() { return scope.sortFactory(); } @Override - protected LuceneSearchAggregationFactory aggregationFactory() { + protected LuceneSearchAggregationFactory aggregationFactory() { return scope.aggregationFactory(); } diff --git a/lucene-next/backend/lucene/src/main/java/org/hibernate/search/backend/lucene/search/query/dsl/impl/LuceneSearchQuerySelectStepImpl.java b/lucene-next/backend/lucene/src/main/java/org/hibernate/search/backend/lucene/search/query/dsl/impl/LuceneSearchQuerySelectStepImpl.java index 4ed9a537a84..2a1283cb6e3 100644 --- a/lucene-next/backend/lucene/src/main/java/org/hibernate/search/backend/lucene/search/query/dsl/impl/LuceneSearchQuerySelectStepImpl.java +++ b/lucene-next/backend/lucene/src/main/java/org/hibernate/search/backend/lucene/search/query/dsl/impl/LuceneSearchQuerySelectStepImpl.java @@ -26,15 +26,16 @@ import org.hibernate.search.engine.search.projection.spi.ProjectionCompositor; import org.hibernate.search.engine.search.query.dsl.spi.AbstractSearchQuerySelectStep; -public class LuceneSearchQuerySelectStepImpl +public class LuceneSearchQuerySelectStepImpl extends AbstractSearchQuerySelectStep< - LuceneSearchQueryOptionsStep, + SR, + LuceneSearchQueryOptionsStep, R, E, LOS, - LuceneSearchProjectionFactory, - LuceneSearchPredicateFactory> - implements LuceneSearchQuerySelectStep { + LuceneSearchProjectionFactory, + LuceneSearchPredicateFactory> + implements LuceneSearchQuerySelectStep { private final LuceneSearchQueryIndexScope scope; private final BackendSessionContext sessionContext; @@ -49,56 +50,56 @@ public LuceneSearchQuerySelectStepImpl(LuceneSearchQueryIndexScope scope, } @Override - public LuceneSearchQueryWhereStep selectEntity() { - return select( scope.projectionFactory().entity().toProjection() ); + public LuceneSearchQueryWhereStep selectEntity() { + return select( scope.projectionFactory().entity().toProjection() ); } @Override - public LuceneSearchQueryWhereStep selectEntityReference() { + public LuceneSearchQueryWhereStep selectEntityReference() { return select( scope.projectionBuilders().entityReference() ); } @Override - public

LuceneSearchQueryWhereStep select(Class

objectClass) { + public

LuceneSearchQueryWhereStep select(Class

objectClass) { return select( scope.projectionFactory().composite().as( objectClass ).toProjection() ); } @Override - public

LuceneSearchQueryWhereStep select( - Function, ? extends ProjectionFinalStep

> projectionContributor) { + public

LuceneSearchQueryWhereStep select( + Function, ? extends ProjectionFinalStep

> projectionContributor) { SearchProjection

projection = projectionContributor.apply( scope.projectionFactory() ).toProjection(); return select( projection ); } @Override - public

LuceneSearchQueryWhereStep select(SearchProjection

projection) { + public

LuceneSearchQueryWhereStep select(SearchProjection

projection) { LuceneSearchQueryBuilder

builder = scope.select( sessionContext, loadingContextBuilder, projection ); return new LuceneSearchQueryOptionsStepImpl<>( scope, builder, loadingContextBuilder ); } @Override - public LuceneSearchQueryWhereStep, LOS> select(SearchProjection... projections) { + public LuceneSearchQueryWhereStep, LOS> select(SearchProjection... projections) { return select( scope.projectionBuilders().composite() .build( projections, ProjectionCompositor.fromList( projections.length ), ProjectionCollector.nullable() ) ); } @Override - public LuceneSearchQueryOptionsStep where(SearchPredicate predicate) { + public LuceneSearchQueryOptionsStep where(SearchPredicate predicate) { return selectEntity().where( predicate ); } @Override - public LuceneSearchQueryOptionsStep where( - Function predicateContributor) { + public LuceneSearchQueryOptionsStep where( + Function, ? extends PredicateFinalStep> predicateContributor) { return selectEntity().where( predicateContributor ); } @Override - public LuceneSearchQueryOptionsStep where( - BiConsumer> predicateContributor) { + public LuceneSearchQueryOptionsStep where( + BiConsumer, + ? super SimpleBooleanPredicateClausesCollector> predicateContributor) { return selectEntity().where( predicateContributor ); } diff --git a/lucene-next/backend/lucene/src/main/java/org/hibernate/search/backend/lucene/search/query/impl/LuceneSearchQueryIndexScope.java b/lucene-next/backend/lucene/src/main/java/org/hibernate/search/backend/lucene/search/query/impl/LuceneSearchQueryIndexScope.java index e9568937880..026703216b8 100644 --- a/lucene-next/backend/lucene/src/main/java/org/hibernate/search/backend/lucene/search/query/impl/LuceneSearchQueryIndexScope.java +++ b/lucene-next/backend/lucene/src/main/java/org/hibernate/search/backend/lucene/search/query/impl/LuceneSearchQueryIndexScope.java @@ -36,16 +36,16 @@

LuceneSearchQueryBuilder

select(BackendSessionContext sessionContext, SearchLoadingContextBuilder loadingContextBuilder, SearchProjection

projection); @Override - LuceneSearchPredicateFactory predicateFactory(); + LuceneSearchPredicateFactory predicateFactory(); @Override - LuceneSearchSortFactory sortFactory(); + LuceneSearchSortFactory sortFactory(); @Override - LuceneSearchProjectionFactory projectionFactory(); + LuceneSearchProjectionFactory projectionFactory(); @Override - LuceneSearchAggregationFactory aggregationFactory(); + LuceneSearchAggregationFactory aggregationFactory(); Query filterOrNull(String tenantId); diff --git a/lucene-next/backend/lucene/src/main/java/org/hibernate/search/backend/lucene/search/sort/dsl/LuceneSearchSortFactory.java b/lucene-next/backend/lucene/src/main/java/org/hibernate/search/backend/lucene/search/sort/dsl/LuceneSearchSortFactory.java index 089b619e4c9..452199ba1dd 100644 --- a/lucene-next/backend/lucene/src/main/java/org/hibernate/search/backend/lucene/search/sort/dsl/LuceneSearchSortFactory.java +++ b/lucene-next/backend/lucene/src/main/java/org/hibernate/search/backend/lucene/search/sort/dsl/LuceneSearchSortFactory.java @@ -14,8 +14,8 @@ /** * A factory for search sorts with some Lucene-specific methods. */ -public interface LuceneSearchSortFactory - extends ExtendedSearchSortFactory { +public interface LuceneSearchSortFactory + extends ExtendedSearchSortFactory, LuceneSearchPredicateFactory> { /** * Order elements by a given Lucene {@link SortField}. @@ -24,7 +24,7 @@ public interface LuceneSearchSortFactory * @return A {@link SortThenStep} allowing the retrieval of the sort * or the chaining of other sorts. */ - SortThenStep fromLuceneSortField(SortField luceneSortField); + SortThenStep fromLuceneSortField(SortField luceneSortField); /** * Order elements by a given Lucene {@link Sort}. @@ -33,6 +33,6 @@ public interface LuceneSearchSortFactory * @return A {@link SortThenStep} allowing the retrieval of the sort * or the chaining of other sorts. */ - SortThenStep fromLuceneSort(Sort luceneSort); + SortThenStep fromLuceneSort(Sort luceneSort); } diff --git a/lucene-next/backend/lucene/src/main/java/org/hibernate/search/backend/lucene/search/sort/dsl/impl/LuceneSearchSortFactoryImpl.java b/lucene-next/backend/lucene/src/main/java/org/hibernate/search/backend/lucene/search/sort/dsl/impl/LuceneSearchSortFactoryImpl.java index 4281a1156d6..925879d6e3a 100644 --- a/lucene-next/backend/lucene/src/main/java/org/hibernate/search/backend/lucene/search/sort/dsl/impl/LuceneSearchSortFactoryImpl.java +++ b/lucene-next/backend/lucene/src/main/java/org/hibernate/search/backend/lucene/search/sort/dsl/impl/LuceneSearchSortFactoryImpl.java @@ -14,32 +14,33 @@ import org.apache.lucene.search.Sort; import org.apache.lucene.search.SortField; -public class LuceneSearchSortFactoryImpl +public class LuceneSearchSortFactoryImpl extends AbstractSearchSortFactory< - LuceneSearchSortFactory, + SR, + LuceneSearchSortFactory, LuceneSearchSortIndexScope, - LuceneSearchPredicateFactory> - implements LuceneSearchSortFactory { + LuceneSearchPredicateFactory> + implements LuceneSearchSortFactory { public LuceneSearchSortFactoryImpl( - SearchSortDslContext, LuceneSearchPredicateFactory> dslContext) { + SearchSortDslContext, LuceneSearchPredicateFactory> dslContext) { super( dslContext ); } @Override - public LuceneSearchSortFactory withRoot(String objectFieldPath) { - return new LuceneSearchSortFactoryImpl( dslContext.rescope( + public LuceneSearchSortFactory withRoot(String objectFieldPath) { + return new LuceneSearchSortFactoryImpl( dslContext.rescope( dslContext.scope().withRoot( objectFieldPath ), dslContext.predicateFactory().withRoot( objectFieldPath ) ) ); } @Override - public SortThenStep fromLuceneSortField(SortField luceneSortField) { + public SortThenStep fromLuceneSortField(SortField luceneSortField) { return staticThenStep( dslContext.scope().sortBuilders().fromLuceneSortField( luceneSortField ) ); } @Override - public SortThenStep fromLuceneSort(Sort luceneSort) { + public SortThenStep fromLuceneSort(Sort luceneSort) { return staticThenStep( dslContext.scope().sortBuilders().fromLuceneSort( luceneSort ) ); }