-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #35026 from marko-bekhta/feat/i32760-search-progra…
…mmatic-mapping Add support for programmatic mapping and mapping configurers
- Loading branch information
Showing
20 changed files
with
498 additions
and
4 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
24 changes: 24 additions & 0 deletions
24
...uarkus/it/hibernate/search/orm/elasticsearch/mapping/AbstractCustomMappingConfigurer.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,24 @@ | ||
package io.quarkus.it.hibernate.search.orm.elasticsearch.mapping; | ||
|
||
import org.hibernate.search.mapper.orm.mapping.HibernateOrmMappingConfigurationContext; | ||
import org.hibernate.search.mapper.orm.mapping.HibernateOrmSearchMappingConfigurer; | ||
import org.hibernate.search.mapper.pojo.mapping.definition.programmatic.TypeMappingStep; | ||
|
||
public abstract class AbstractCustomMappingConfigurer implements HibernateOrmSearchMappingConfigurer { | ||
|
||
private final Class<?> type; | ||
private final String indexName; | ||
|
||
protected AbstractCustomMappingConfigurer(Class<?> type, String indexName) { | ||
this.type = type; | ||
this.indexName = indexName; | ||
} | ||
|
||
@Override | ||
public void configure(HibernateOrmMappingConfigurationContext context) { | ||
TypeMappingStep type = context.programmaticMapping().type(this.type); | ||
type.indexed().index(this.indexName); | ||
type.property("id").documentId(); | ||
type.property("text").fullTextField(); | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
...it/hibernate/search/orm/elasticsearch/mapping/CustomApplicationBeanMappingConfigurer.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,26 @@ | ||
package io.quarkus.it.hibernate.search.orm.elasticsearch.mapping; | ||
|
||
import jakarta.enterprise.context.ApplicationScoped; | ||
import jakarta.inject.Inject; | ||
import jakarta.inject.Named; | ||
|
||
import org.hibernate.search.mapper.orm.mapping.HibernateOrmMappingConfigurationContext; | ||
|
||
import io.quarkus.it.hibernate.search.orm.elasticsearch.analysis.MyCdiContext; | ||
|
||
@ApplicationScoped | ||
@Named("custom-application-bean-mapping-configurer") | ||
public class CustomApplicationBeanMappingConfigurer extends AbstractCustomMappingConfigurer { | ||
@Inject | ||
MyCdiContext cdiContext; | ||
|
||
public CustomApplicationBeanMappingConfigurer() { | ||
super(MappingTestingApplicationBeanEntity.class, MappingTestingApplicationBeanEntity.INDEX); | ||
} | ||
|
||
@Override | ||
public void configure(HibernateOrmMappingConfigurationContext context) { | ||
MyCdiContext.checkAvailable(cdiContext); | ||
super.configure(context); | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
...o/quarkus/it/hibernate/search/orm/elasticsearch/mapping/CustomClassMappingConfigurer.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,24 @@ | ||
package io.quarkus.it.hibernate.search.orm.elasticsearch.mapping; | ||
|
||
import jakarta.inject.Inject; | ||
|
||
import org.hibernate.search.mapper.orm.mapping.HibernateOrmMappingConfigurationContext; | ||
|
||
import io.quarkus.it.hibernate.search.orm.elasticsearch.analysis.MyCdiContext; | ||
|
||
public class CustomClassMappingConfigurer extends AbstractCustomMappingConfigurer { | ||
|
||
@Inject | ||
MyCdiContext cdiContext; | ||
|
||
public CustomClassMappingConfigurer() { | ||
super(MappingTestingClassEntity.class, MappingTestingClassEntity.INDEX); | ||
} | ||
|
||
@Override | ||
public void configure(HibernateOrmMappingConfigurationContext context) { | ||
MyCdiContext.checkNotAvailable(cdiContext); | ||
|
||
super.configure(context); | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
...s/it/hibernate/search/orm/elasticsearch/mapping/CustomDependentBeanMappingConfigurer.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,26 @@ | ||
package io.quarkus.it.hibernate.search.orm.elasticsearch.mapping; | ||
|
||
import jakarta.enterprise.context.Dependent; | ||
import jakarta.inject.Inject; | ||
import jakarta.inject.Named; | ||
|
||
import org.hibernate.search.mapper.orm.mapping.HibernateOrmMappingConfigurationContext; | ||
|
||
import io.quarkus.it.hibernate.search.orm.elasticsearch.analysis.MyCdiContext; | ||
|
||
@Dependent | ||
@Named("custom-dependent-bean-mapping-configurer") | ||
public class CustomDependentBeanMappingConfigurer extends AbstractCustomMappingConfigurer { | ||
@Inject | ||
MyCdiContext cdiContext; | ||
|
||
public CustomDependentBeanMappingConfigurer() { | ||
super(MappingTestingDependentBeanEntity.class, MappingTestingDependentBeanEntity.INDEX); | ||
} | ||
|
||
@Override | ||
public void configure(HibernateOrmMappingConfigurationContext context) { | ||
MyCdiContext.checkAvailable(cdiContext); | ||
super.configure(context); | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
...it/hibernate/search/orm/elasticsearch/mapping/CustomSearchExtensionMappingConfigurer.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,24 @@ | ||
package io.quarkus.it.hibernate.search.orm.elasticsearch.mapping; | ||
|
||
import jakarta.inject.Inject; | ||
|
||
import org.hibernate.search.mapper.orm.mapping.HibernateOrmMappingConfigurationContext; | ||
|
||
import io.quarkus.hibernate.search.orm.elasticsearch.SearchExtension; | ||
import io.quarkus.it.hibernate.search.orm.elasticsearch.analysis.MyCdiContext; | ||
|
||
@SearchExtension | ||
public class CustomSearchExtensionMappingConfigurer extends AbstractCustomMappingConfigurer { | ||
@Inject | ||
MyCdiContext cdiContext; | ||
|
||
public CustomSearchExtensionMappingConfigurer() { | ||
super(MappingTestingSearchExtensionEntity.class, MappingTestingSearchExtensionEntity.INDEX); | ||
} | ||
|
||
@Override | ||
public void configure(HibernateOrmMappingConfigurationContext context) { | ||
MyCdiContext.checkAvailable(cdiContext); | ||
super.configure(context); | ||
} | ||
} |
Oops, something went wrong.