【发布时间】:2021-11-21 15:20:23
【问题描述】:
我正在尝试管理一个类的休眠搜索索引,该类的字段由@IndexedEmbedded 在自定义@Embeddable 实体上映射。该实体还包含@MappedSuperclass 中的其他@IndexedEmbedded 字段。 这些是涉及的实体:
@Builder
@Entity
@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
@ToString
@Indexed
@GeoPointBinding(fieldName = "location")
public class Insertion {
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "INSERTION_SEQ")
private Long id;
@NotNull
@GenericField
private Boolean publicated;
@NotNull
@Latitude
private Double latitude;
@NotNull
@Longitude
private Double longitude;
@JsonIgnore
private Point location;
@FullTextField(analyzer = "generic_text")
@KeywordField(name="city_sort", sortable = Sortable.YES, normalizer = "sort")
private String city;
@NotNull
@Embedded
@Valid
@IndexedEmbedded
private Amount amount;
@IndexedEmbedded(name = "insertion_mate_preferences")
@Embedded
@Valid
private MatePreference matePreferences;
}
还有这些类:
@SuperBuilder
@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
@Embeddable
public class MatePreference extends BaseProfile {
@NotNull
@GenericField
private Integer minAge;
@NotNull
@GenericField
private Integer maxAge;
}
@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
@SuperBuilder
@MappedSuperclass
public abstract class BaseProfile implements BaseProfileView {
@GenericField
private Boolean smoker;
@GenericField
private Boolean children;
@GenericField
private Boolean hasAnimals;
@GenericField
private Boolean student;
@GenericField
private Boolean employed;
@GenericField
private String animalsDescription;
@Enumerated(EnumType.STRING)
@GenericField
private Genre genre;
@Enumerated(EnumType.STRING)
@GenericField
private OccupationSector occupation;
@Enumerated(EnumType.STRING)
@ElementCollection(fetch = FetchType.EAGER)
@GenericField
@IndexedEmbedded
private Set<Personality> personalities;
@Enumerated(EnumType.STRING)
@ElementCollection(fetch = FetchType.EAGER)
@GenericField
@IndexedEmbedded
private Set<Lifestyle> lifestyles;
@ElementCollection(fetch = FetchType.EAGER)
@GenericField
@IndexedEmbedded
private Set<Language> languages;
@Enumerated(EnumType.STRING)
@GenericField
private StudyTitle titleOfStudy;
@Enumerated(EnumType.STRING)
@GenericField
private StudyField studyField;
}
运行应用程序时,Hibernate Search 会抛出以下错误:
org.hibernate.search.util.common.SearchException: HSEARCH000520: Hibernate Search encountered failures during bootstrap. Failures:
Hibernate ORM mapping:
type 'it.friendshome.api.common.model.insertion.Insertion':
path '.matePreferences<no value extractors>.languages':
index 'Insertion':
field 'insertion_mate_preferences':
failures:
- HSEARCH400520: Duplicate index field definition: 'languages'. Index field names must be unique. Look for two property mappings with the same field name, or two indexed-embeddeds with prefixes that lead to conflicting index field names, or two custom bridges declaring index fields with the same name.
path '.matePreferences<no value extractors>.lifestyles':
index 'Insertion':
field 'insertion_mate_preferences':
failures:
- HSEARCH400520: Duplicate index field definition: 'lifestyles'. Index field names must be unique. Look for two property mappings with the same field name, or two indexed-embeddeds with prefixes that lead to conflicting index field names, or two custom bridges declaring index fields with the same name.
path '.matePreferences<no value extractors>.personalities':
index 'Insertion':
field 'insertion_mate_preferences':
failures:
- HSEARCH400520: Duplicate index field definition: 'personalities'. Index field names must be unique. Look for two property mappings with the same field name, or two indexed-embeddeds with prefixes that lead to conflicting index field names, or two custom bridges declaring index fields with the same name.
type 'it.friendshome.api.common.model.profile.Profile':
path '.languages':
index 'Profile':
index schema root:
failures:
- HSEARCH400520: Duplicate index field definition: 'languages'. Index field names must be unique. Look for two property mappings with the same field name, or two indexed-embeddeds with prefixes that lead to conflicting index field names, or two custom bridges declaring index fields with the same name.
path '.lifestyles':
index 'Profile':
index schema root:
failures:
- HSEARCH400520: Duplicate index field definition: 'lifestyles'. Index field names must be unique. Look for two property mappings with the same field name, or two indexed-embeddeds with prefixes that lead to conflicting index field names, or two custom bridges declaring index fields with the same name.
path '.personalities':
index 'Profile':
index schema root:
failures:
- HSEARCH400520: Duplicate index field definition: 'personalities'. Index field names must be unique. Look for two property mappings with the same field name, or two indexed-embeddeds with prefixes that lead to conflicting index field names, or two custom bridges declaring index fields with the same name.
type 'it.friendshome.api.common.model.search.Search':
path '.matePreference<no value extractors>.languages':
index 'Search':
field 'matePreference':
failures:
- HSEARCH400520: Duplicate index field definition: 'languages'. Index field names must be unique. Look for two property mappings with the same field name, or two indexed-embeddeds with prefixes that lead to conflicting index field names, or two custom bridges declaring index fields with the same name.
path '.matePreference<no value extractors>.lifestyles':
index 'Search':
field 'matePreference':
failures:
- HSEARCH400520: Duplicate index field definition: 'lifestyles'. Index field names must be unique. Look for two property mappings with the same field name, or two indexed-embeddeds with prefixes that lead to conflicting index field names, or two custom bridges declaring index fields with the same name.
path '.matePreference<no value extractors>.personalities':
index 'Search':
field 'matePreference':
failures:
- HSEARCH400520: Duplicate index field definition: 'personalities'. Index field names must be unique. Look for two property mappings with the same field name, or two indexed-embeddeds with prefixes that lead to conflicting index field names, or two custom bridges declaring index fields with the same name.
我使用以下依赖项运行它:
关于如何管理这种情况有什么建议吗?
【问题讨论】:
标签: java hibernate elasticsearch quarkus hibernate-search