Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import org.hibernate.search.backend.elasticsearch.analysis.model.dsl.ElasticsearchAnalyzerTypeStep;
import org.hibernate.search.backend.elasticsearch.analysis.model.dsl.ElasticsearchAnalyzerTokenizerStep;
import org.hibernate.search.backend.elasticsearch.analysis.ElasticsearchAnalysisConfigurationContext;
import org.hibernate.search.backend.elasticsearch.analysis.model.dsl.ElasticsearchNormalizerOptionalComponentsStep;
import org.hibernate.search.backend.elasticsearch.analysis.model.dsl.ElasticsearchNormalizerTypeStep;
import org.hibernate.search.backend.elasticsearch.analysis.model.dsl.ElasticsearchAnalysisComponentParametersStep;
import org.hibernate.search.backend.elasticsearch.analysis.model.impl.ElasticsearchAnalysisDefinitionCollector;
Expand Down Expand Up @@ -49,14 +48,11 @@ public ElasticsearchAnalysisComponentParametersStep type(String type) {

@Override
public ElasticsearchNormalizerTypeStep normalizer(String name) {
return new ElasticsearchNormalizerTypeStep() {
@Override
public ElasticsearchNormalizerOptionalComponentsStep custom() {
ElasticsearchNormalizerComponentsStep context =
new ElasticsearchNormalizerComponentsStep( name );
children.add( context );
return context;
}
return () -> {
ElasticsearchNormalizerComponentsStep context =
new ElasticsearchNormalizerComponentsStep( name );
children.add( context );
return context;
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,12 @@
*/
public class ElasticsearchClientFactoryImpl implements ElasticsearchClientFactory {

public static final BeanReference<ElasticsearchClientFactory> REFERENCE = new BeanReference<ElasticsearchClientFactory>() {
@Override
public BeanHolder<ElasticsearchClientFactory> resolve(BeanResolver beanResolver) {
BeanHolder<List<ElasticsearchHttpClientConfigurer>> httpClientConfigurerHolders =
beanResolver.resolveRole( ElasticsearchHttpClientConfigurer.class );
ElasticsearchClientFactoryImpl factory = new ElasticsearchClientFactoryImpl( httpClientConfigurerHolders.get() );
return BeanHolder.<ElasticsearchClientFactory>of( factory )
.withDependencyAutoClosing( httpClientConfigurerHolders );
}
public static final BeanReference<ElasticsearchClientFactory> REFERENCE = (BeanResolver beanResolver) -> {
BeanHolder<List<ElasticsearchHttpClientConfigurer>> httpClientConfigurerHolders =
beanResolver.resolveRole( ElasticsearchHttpClientConfigurer.class );
ElasticsearchClientFactoryImpl factory = new ElasticsearchClientFactoryImpl( httpClientConfigurerHolders.get() );
return BeanHolder.<ElasticsearchClientFactory>of( factory )
.withDependencyAutoClosing( httpClientConfigurerHolders );
};

private static final ConfigurationProperty<List<String>> HOST =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -333,16 +333,11 @@ public void elasticsearch() {
}

private MySearchParameters getSearchParameters() {
return new MySearchParameters() {
@Override
public List<MySort> getSorts() {
return Arrays.asList(
new MySort( MySortType.GENRE, SortOrder.ASC ),
new MySort( MySortType.TITLE, SortOrder.DESC ),
new MySort( MySortType.PAGE_COUNT, SortOrder.DESC )
);
}
};
return () -> Arrays.asList(
new MySort( MySortType.GENRE, SortOrder.ASC ),
new MySort( MySortType.TITLE, SortOrder.DESC ),
new MySort( MySortType.PAGE_COUNT, SortOrder.DESC )
);
}

private void withinSearchSession(Consumer<SearchSession> action) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,48 +13,45 @@
import java.util.Optional;
import java.util.stream.Collectors;

import org.apache.http.nio.client.HttpAsyncClient;
import org.assertj.core.api.Assertions;
import org.assertj.core.api.HamcrestCondition;
import org.elasticsearch.client.Request;
import org.elasticsearch.client.Response;
import org.elasticsearch.client.RestClient;
import org.hibernate.search.backend.elasticsearch.ElasticsearchBackend;
import org.hibernate.search.backend.elasticsearch.ElasticsearchExtension;
import org.hibernate.search.backend.elasticsearch.impl.ElasticsearchIndexNameNormalizer;
import org.hibernate.search.backend.elasticsearch.index.ElasticsearchIndexManager;
import org.hibernate.search.backend.elasticsearch.search.dsl.query.ElasticsearchSearchQueryHitTypeStep;
import org.hibernate.search.backend.elasticsearch.search.dsl.query.ElasticsearchSearchQueryOptionsStep;
import org.hibernate.search.backend.elasticsearch.search.dsl.query.ElasticsearchSearchQueryPredicateStep;
import org.hibernate.search.backend.elasticsearch.search.dsl.query.ElasticsearchSearchQueryHitTypeStep;
import org.hibernate.search.backend.elasticsearch.search.query.ElasticsearchSearchQuery;
import org.hibernate.search.backend.elasticsearch.search.query.ElasticsearchSearchResult;
import org.hibernate.search.engine.backend.Backend;
import org.hibernate.search.engine.backend.document.DocumentElement;
import org.hibernate.search.engine.backend.document.IndexFieldReference;
import org.hibernate.search.engine.backend.document.model.dsl.IndexSchemaElement;
import org.hibernate.search.engine.backend.index.IndexManager;
import org.hibernate.search.engine.search.SearchProjection;
import org.hibernate.search.engine.search.loading.context.spi.LoadingContext;
import org.hibernate.search.engine.search.query.SearchQueryExtension;
import org.hibernate.search.util.impl.integrationtest.common.stub.mapper.StubMappingScope;
import org.hibernate.search.engine.backend.work.execution.spi.IndexWorkPlan;
import org.hibernate.search.engine.common.spi.SearchIntegration;
import org.hibernate.search.util.impl.integrationtest.common.stub.mapper.StubMappingIndexManager;
import org.hibernate.search.engine.search.DocumentReference;
import org.hibernate.search.engine.search.SearchPredicate;
import org.hibernate.search.engine.search.query.SearchQuery;
import org.hibernate.search.engine.search.SearchProjection;
import org.hibernate.search.engine.search.SearchSort;
import org.hibernate.search.engine.search.loading.context.spi.LoadingContext;
import org.hibernate.search.engine.search.query.SearchQuery;
import org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper;
import org.hibernate.search.util.common.SearchException;
import org.hibernate.search.util.impl.integrationtest.common.stub.mapper.StubMappingIndexManager;
import org.hibernate.search.util.impl.integrationtest.common.stub.mapper.StubMappingScope;
import org.hibernate.search.util.impl.test.ExceptionMatcherBuilder;
import org.hibernate.search.util.impl.test.SubTest;

import org.json.JSONException;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;

import org.apache.http.nio.client.HttpAsyncClient;
import org.assertj.core.api.Assertions;
import org.assertj.core.api.HamcrestCondition;
import org.elasticsearch.client.Request;
import org.elasticsearch.client.Response;
import org.elasticsearch.client.RestClient;
import org.json.JSONException;
import org.skyscreamer.jsonassert.JSONAssert;
import org.skyscreamer.jsonassert.JSONCompareMode;

Expand Down Expand Up @@ -164,13 +161,7 @@ public void query() {

// Unsupported extension
SubTest.expectException(
() -> query.extension( new SearchQueryExtension<Void, DocumentReference>() {
@Override
public Optional<Void> extendOptional(SearchQuery<DocumentReference> original,
LoadingContext<?, ?> loadingContext) {
return Optional.empty();
}
} )
() -> query.extension( (SearchQuery<DocumentReference> original, LoadingContext<?, ?> loadingContext) -> Optional.empty() )
)
.assertThrown()
.isInstanceOf( SearchException.class );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1158,17 +1158,11 @@ private SearchSetupHelper.SetupContext validateSchemaConfig() {
ElasticsearchIndexSettings.LIFECYCLE_STRATEGY,
IndexLifecycleStrategyName.VALIDATE.getExternalRepresentation()
)
.withBackendProperty(
BACKEND_NAME,
.withBackendProperty( BACKEND_NAME,
// Don't contribute any analysis definitions, migration of those is tested in another test class
ElasticsearchBackendSettings.ANALYSIS_CONFIGURER,
new ElasticsearchAnalysisConfigurer() {
@Override
public void configure(ElasticsearchAnalysisConfigurationContext context) {
// No-op
}
}
);
ElasticsearchBackendSettings.ANALYSIS_CONFIGURER, (ElasticsearchAnalysisConfigurer) (ElasticsearchAnalysisConfigurationContext context) -> {
// No-op
} );
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,17 +89,11 @@ private void setup() {
ElasticsearchIndexSettings.LIFECYCLE_STRATEGY,
IndexLifecycleStrategyName.CREATE.getExternalRepresentation()
)
.withBackendProperty(
BACKEND_NAME,
.withBackendProperty( BACKEND_NAME,
// Don't contribute any analysis definitions, migration of those is tested in another test class
ElasticsearchBackendSettings.ANALYSIS_CONFIGURER,
new ElasticsearchAnalysisConfigurer() {
@Override
public void configure(ElasticsearchAnalysisConfigurationContext context) {
// No-op
}
}
)
ElasticsearchBackendSettings.ANALYSIS_CONFIGURER, (ElasticsearchAnalysisConfigurer) (ElasticsearchAnalysisConfigurationContext context) -> {
// No-op
} )
.setup();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -207,17 +207,11 @@ private void setup(Consumer<IndexBindingContext> mappingContributor) {
ElasticsearchIndexSettings.LIFECYCLE_STRATEGY,
strategy.getExternalRepresentation()
)
.withBackendProperty(
BACKEND_NAME,
.withBackendProperty( BACKEND_NAME,
// Don't contribute any analysis definitions, migration of those is tested in another test class
ElasticsearchBackendSettings.ANALYSIS_CONFIGURER,
new ElasticsearchAnalysisConfigurer() {
@Override
public void configure(ElasticsearchAnalysisConfigurationContext context) {
// No-op
}
}
)
ElasticsearchBackendSettings.ANALYSIS_CONFIGURER, (ElasticsearchAnalysisConfigurer) (ElasticsearchAnalysisConfigurationContext context) -> {
// No-op
} )
.setup();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -467,17 +467,11 @@ private SearchSetupHelper.SetupContext withManagementStrategyConfiguration() {
ElasticsearchIndexSettings.LIFECYCLE_STRATEGY,
IndexLifecycleStrategyName.UPDATE.getExternalRepresentation()
)
.withBackendProperty(
BACKEND_NAME,
.withBackendProperty( BACKEND_NAME,
// Don't contribute any analysis definitions, migration of those is tested in another test class
ElasticsearchBackendSettings.ANALYSIS_CONFIGURER,
new ElasticsearchAnalysisConfigurer() {
@Override
public void configure(ElasticsearchAnalysisConfigurationContext context) {
// No-op
}
}
);
ElasticsearchBackendSettings.ANALYSIS_CONFIGURER, (ElasticsearchAnalysisConfigurer) (ElasticsearchAnalysisConfigurationContext context) -> {
// No-op
} );
}

private String generateAnalysisSettings() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -548,16 +548,10 @@ private SearchSetupHelper.SetupContext validateSchemaConfig() {
ElasticsearchIndexSettings.LIFECYCLE_STRATEGY,
IndexLifecycleStrategyName.VALIDATE.getExternalRepresentation()
)
.withBackendProperty(
BACKEND_NAME,
.withBackendProperty( BACKEND_NAME,
// Don't contribute any analysis definitions, migration of those is tested in another test class
ElasticsearchBackendSettings.ANALYSIS_CONFIGURER,
new ElasticsearchAnalysisConfigurer() {
@Override
public void configure(ElasticsearchAnalysisConfigurationContext context) {
// No-op
}
}
);
ElasticsearchBackendSettings.ANALYSIS_CONFIGURER, (ElasticsearchAnalysisConfigurer) (ElasticsearchAnalysisConfigurationContext context) -> {
// No-op
} );
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@
import org.hibernate.search.engine.common.spi.SearchIntegration;
import org.hibernate.search.engine.search.SearchProjection;
import org.hibernate.search.engine.search.loading.context.spi.LoadingContext;
import org.hibernate.search.engine.search.query.SearchQueryExtension;
import org.hibernate.search.util.impl.integrationtest.common.stub.mapper.StubMappingIndexManager;
import org.hibernate.search.util.impl.integrationtest.common.stub.mapper.StubMappingScope;
import org.hibernate.search.backend.lucene.LuceneExtension;
Expand Down Expand Up @@ -174,13 +173,7 @@ public void query() {

// Unsupported extension
SubTest.expectException(
() -> query.extension( new SearchQueryExtension<Void, DocumentReference>() {
@Override
public Optional<Void> extendOptional(SearchQuery<DocumentReference> original,
LoadingContext<?, ?> loadingContext) {
return Optional.empty();
}
} )
() -> query.extension( (SearchQuery<DocumentReference> original, LoadingContext<?, ?> loadingContext) -> Optional.empty() )
)
.assertThrown()
.isInstanceOf( SearchException.class );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,17 +100,11 @@ public String getStringProperty() {
f -> f.asString().analyzer( "myAnalyzer" )
)
.toReference();
context.setBridge(
new PropertyBridge() {
@Override
public void write(DocumentElement target, Object bridgedElement,
PropertyBridgeWriteContext context) {
target.addValue(
indexFieldReference, pojoPropertyAccessor.read( bridgedElement )
);
}
}
);
context.setBridge( (DocumentElement target, Object bridgedElement, PropertyBridgeWriteContext context1) -> {
target.addValue(
indexFieldReference, pojoPropertyAccessor.read( bridgedElement )
);
} );
} )
)
.setup( IndexedEntity.class );
Expand Down Expand Up @@ -184,18 +178,12 @@ public Contained getContained() {
f -> f.asString().analyzer( "myAnalyzer" )
)
.toReference();
context.setBridge(
new PropertyBridge() {
@Override
public void write(DocumentElement target, Object bridgedElement,
PropertyBridgeWriteContext context) {
Contained castedBridgedElement = (Contained) bridgedElement;
target.addValue(
indexFieldReference, castedBridgedElement.getStringProperty()
);
}
}
);
context.setBridge( (DocumentElement target, Object bridgedElement, PropertyBridgeWriteContext context1) -> {
Contained castedBridgedElement = (Contained) bridgedElement;
target.addValue(
indexFieldReference, castedBridgedElement.getStringProperty()
);
} );
} )
)
.setup( IndexedEntity.class );
Expand Down Expand Up @@ -352,20 +340,16 @@ public void explicitReindexing() {
f -> f.asString().analyzer( "myAnalyzer" )
)
.toReference();
context.setBridge( new PropertyBridge() {
@Override
public void write(DocumentElement target, Object bridgedElement,
PropertyBridgeWriteContext context) {
PropertyBridgeExplicitIndexingClasses.ContainedLevel1Entity castedBridgedElement =
(PropertyBridgeExplicitIndexingClasses.ContainedLevel1Entity) bridgedElement;
/*
* In a real application this would run a query,
* but we don't have the necessary infrastructure here
* so we'll cut short and just index a constant.
* We just need to know the bridge is executed anyway.
*/
target.addValue( indexFieldReference, "constant" );
}
context.setBridge( (DocumentElement target, Object bridgedElement, PropertyBridgeWriteContext context1) -> {
PropertyBridgeExplicitIndexingClasses.ContainedLevel1Entity castedBridgedElement =
(PropertyBridgeExplicitIndexingClasses.ContainedLevel1Entity) bridgedElement;
/*
* In a real application this would run a query,
* but we don't have the necessary infrastructure here
* so we'll cut short and just index a constant.
* We just need to know the bridge is executed anyway.
*/
target.addValue( indexFieldReference, "constant" );
} );
} )
)
Expand Down Expand Up @@ -800,14 +784,10 @@ public List<String> getStringProperty() {
f -> f.asString().analyzer( "myAnalyzer" )
)
.toReference();
context.setBridge( new PropertyBridge() {
@Override
public void write(DocumentElement target, Object bridgedElement,
PropertyBridgeWriteContext context) {
List<String> castedBridgedElement = (List<String>) bridgedElement;
for ( String string : castedBridgedElement ) {
target.addValue( indexFieldReference, string );
}
context.setBridge( (DocumentElement target, Object bridgedElement, PropertyBridgeWriteContext context1) -> {
List<String> castedBridgedElement = (List<String>) bridgedElement;
for ( String string : castedBridgedElement ) {
target.addValue( indexFieldReference, string );
}
} );
} )
Expand Down
Loading