在Hibernate Search中建立索引时出错-无法获得属性值

问题描述 投票:0回答:1

我正在通过Spring Boot使用Hibernate Search来创建可搜索的rest api。尝试发布“培训”实例时,我收到以下堆栈跟踪。两者都不对我很有见识,这就是为什么我要寻求帮助。

堆栈跟踪:https://pastebin.com/pmurg1N3

在我看来,它正在尝试为空实体建立索引!?怎么会这样有什么想法吗?

实体:

@Entity @Getter @Setter @NoArgsConstructor
@ToString(onlyExplicitlyIncluded = true)
@Audited @Indexed(index = "Training")
@AnalyzerDef(name = "ngram",
    tokenizer = @TokenizerDef(factory = StandardTokenizerFactory.class ),
    filters = {
      @TokenFilterDef(factory = StandardFilterFactory.class),
      @TokenFilterDef(factory = LowerCaseFilterFactory.class),
      @TokenFilterDef(factory = StopFilterFactory.class),
      @TokenFilterDef(factory = NGramFilterFactory.class,
        params = {
          @Parameter(name = "minGramSize", value = "2"),
        } 
      )
    }
)
@Analyzer(definition = "ngram")
public class Training implements BaseEntity<Long>, OwnedEntity {

    @Id
    @GeneratedValue
    @ToString.Include
    private Long id;

    @NotNull
    @RestResourceMapper(context = RestResourceContext.IDENTITY, path = "/companies/{id}")
    @JsonProperty(access = Access.WRITE_ONLY)
    @JsonDeserialize(using = RestResourceURLSerializer.class)
    private Long owner;

    @NotNull
    @Field(index = Index.YES, analyze = Analyze.YES, store = Store.YES)
    private String name;

    @Column(length = 10000)
    private String goals;

    @Column(length = 10000)
    private String description;

    @Enumerated(EnumType.STRING)
    @Field(index = Index.YES, store = Store.YES, analyze = Analyze.NO, bridge=@FieldBridge(impl=EnumBridge.class))
    private Audience audience;

    @Enumerated(EnumType.STRING)
    @Field(index = Index.YES, store = Store.YES, analyze = Analyze.NO, bridge=@FieldBridge(impl=EnumBridge.class))
    private Level level;

    @ManyToMany
    @Audited(targetAuditMode = RelationTargetAuditMode.NOT_AUDITED)
    @NotNull @Size(min = 1)
    @IndexedEmbedded
    private Set<ProductVersion> versions;

    @NotNull
    private Boolean enabled = false;

    @NotNull
    @Min(1)
    @IndexedEmbedded
    @Field(index = Index.YES, store = Store.YES, analyze = Analyze.NO)
    @NumericField
    private Integer maxStudents;

    @NotNull
    @ManyToOne(fetch = FetchType.LAZY)
    private Agenda agenda;

    @NotNull
    @Min(1)
    @Field(index = Index.YES, store = Store.YES, analyze = Analyze.NO)
    @NumericField
    private Integer durationDays;

    @IndexedEmbedded
    @Audited(targetAuditMode = RelationTargetAuditMode.NOT_AUDITED)
    @ManyToMany(cascade = CascadeType.PERSIST)
    private Set<Tag> tags = new HashSet<>();
spring-boot hibernate-search
1个回答
0
投票

我想说您的versions集合或tags集合包含null对象,通常这不是我们在Hibernate ORM关联中所期望的,而且显然也不是Hibernate Search所期望的。

您可以在调试模式下检查吗?

© www.soinside.com 2019 - 2024. All rights reserved.