use of org.hibernate.search.mapper.orm.mapping.HibernateOrmSearchMappingConfigurer in project hibernate-search by hibernate.
the class ElasticsearchAnalysisIT method advanced.
@Test
public void advanced() {
EntityManagerFactory entityManagerFactory = setupHelper.start().withBackendProperty(ElasticsearchIndexSettings.ANALYSIS_CONFIGURER, new AdvancedElasticsearchAnalysisConfigurer()).withProperty(HibernateOrmMapperSettings.MAPPING_CONFIGURER, (HibernateOrmSearchMappingConfigurer) context -> context.programmaticMapping().type(IndexedEntity.class).property("text").fullTextField("standard").analyzer("standard")).setup(IndexedEntity.class);
with(entityManagerFactory).runInTransaction(entityManager -> {
IndexedEntity entity = new IndexedEntity();
entity.setText("the Wording");
entityManager.persist(entity);
});
with(entityManagerFactory).runInTransaction(entityManager -> {
SearchSession searchSession = Search.session(entityManager);
assertThat(searchSession.search(IndexedEntity.class).where(f -> f.match().field("standard").matching("wording")).fetchHits(20)).hasSize(1);
});
}
use of org.hibernate.search.mapper.orm.mapping.HibernateOrmSearchMappingConfigurer in project hibernate-search by hibernate.
the class LuceneAnalysisIT method similarity.
@Test
public void similarity() {
EntityManagerFactory entityManagerFactory = setupHelper.start().withBackendProperty(LuceneBackendSettings.ANALYSIS_CONFIGURER, new CustomSimilarityLuceneAnalysisConfigurer()).withProperty(HibernateOrmMapperSettings.MAPPING_CONFIGURER, (HibernateOrmSearchMappingConfigurer) context -> context.programmaticMapping().type(IndexedEntity.class).property("text").fullTextField("standard").analyzer("english")).setup(IndexedEntity.class);
with(entityManagerFactory).runInTransaction(entityManager -> {
IndexedEntity entity = new IndexedEntity();
entity.setText("the Wording");
entityManager.persist(entity);
});
with(entityManagerFactory).runInTransaction(entityManager -> {
SearchSession searchSession = Search.session(entityManager);
assertThat(searchSession.search(IndexedEntity.class).where(f -> f.match().field("standard").matching("wording")).fetchHits(20)).hasSize(1);
});
}
use of org.hibernate.search.mapper.orm.mapping.HibernateOrmSearchMappingConfigurer in project hibernate-search by hibernate.
the class LuceneAnalysisIT method luceneClasses.
@Test
public void luceneClasses() {
EntityManagerFactory entityManagerFactory = setupHelper.start().withBackendProperty(LuceneBackendSettings.ANALYSIS_CONFIGURER, new LuceneClassesAnalysisConfigurer()).withProperty(HibernateOrmMapperSettings.MAPPING_CONFIGURER, (HibernateOrmSearchMappingConfigurer) context -> context.programmaticMapping().type(IndexedEntity.class).property("text").fullTextField("standard").analyzer("english")).setup(IndexedEntity.class);
with(entityManagerFactory).runInTransaction(entityManager -> {
IndexedEntity entity = new IndexedEntity();
entity.setText("the Wording");
entityManager.persist(entity);
});
with(entityManagerFactory).runInTransaction(entityManager -> {
SearchSession searchSession = Search.session(entityManager);
assertThat(searchSession.search(IndexedEntity.class).where(f -> f.match().field("standard").matching("wording")).fetchHits(20)).hasSize(1);
});
}
use of org.hibernate.search.mapper.orm.mapping.HibernateOrmSearchMappingConfigurer in project hibernate-search by hibernate.
the class LuceneAnalysisIT method advanced.
@Test
public void advanced() {
EntityManagerFactory entityManagerFactory = setupHelper.start().withBackendProperty(LuceneBackendSettings.ANALYSIS_CONFIGURER, new AdvancedLuceneAnalysisConfigurer()).withProperty(HibernateOrmMapperSettings.MAPPING_CONFIGURER, (HibernateOrmSearchMappingConfigurer) context -> context.programmaticMapping().type(IndexedEntity.class).property("text").fullTextField("standard").analyzer("my-standard")).setup(IndexedEntity.class);
with(entityManagerFactory).runInTransaction(entityManager -> {
IndexedEntity entity = new IndexedEntity();
entity.setText("the Wording");
entityManager.persist(entity);
});
with(entityManagerFactory).runInTransaction(entityManager -> {
SearchSession searchSession = Search.session(entityManager);
assertThat(searchSession.search(IndexedEntity.class).where(f -> f.match().field("standard").matching("wording")).fetchHits(20)).hasSize(1);
});
}
use of org.hibernate.search.mapper.orm.mapping.HibernateOrmSearchMappingConfigurer in project hibernate-search by hibernate.
the class AnnotationMappingDiscoveryIT method discoveryDisabled.
@Test
public void discoveryDisabled() {
backendMock.expectSchema(IndexedEntity.INDEX, b -> b.objectField("annotationMappedEmbedded", b2 -> {
/*
* This object field should contain only the property mapped using the programmatic API,
* because the annotation mapping for the embedded type has *NOT* been automatically discovered.
*/
b2.field("alwaysPresent", String.class);
}).objectField("nonAnnotationMappedEmbedded", b2 -> {
/*
* This object field should contain only the property mapped using the programmatic API,
* because the annotation mapping for the embedded type has *NOT* been automatically discovered.
*/
b2.field("alwaysPresent", String.class);
}));
ormSetupHelper.start().withProperty(HibernateOrmMapperSettings.MAPPING_PROCESS_ANNOTATIONS, "false").withProperty(HibernateOrmMapperSettings.MAPPING_CONFIGURER, (HibernateOrmSearchMappingConfigurer) context -> {
context.programmaticMapping().type(IndexedEntity.class).property("nonAnnotationMappedEmbedded").indexedEmbedded();
TypeMappingStep indexedEntityMapping = context.programmaticMapping().type(IndexedEntity.class);
indexedEntityMapping.indexed().index(IndexedEntity.INDEX);
indexedEntityMapping.property("id").documentId();
indexedEntityMapping.property("annotationMappedEmbedded").indexedEmbedded();
mapAlwaysPresentProperty(context.programmaticMapping());
}).setup(IndexedEntity.class, NonExplicitlyRegisteredType.class, NonExplicitlyRegisteredNonMappedType.class, NonExplicitlyRegisteredNonAnnotationMappedType.class);
backendMock.verifyExpectationsMet();
}
Aggregations