tissa
tissa

Reputation: 396

HSEARCH 700061: Index a list of enums with Hibernate Search 6

I am new in Hibernate search 6 world, I want to index a list of enum in my entity, but I get unfortunatly this Error

HSEARCH700061: Unable to index-embed type 'com.commons.enums.B

@Entity
@Indexed
public class A {
    @IndexedEmbedded
    @ElementCollection
    @CollectionTable(name = "A_B", joinColumns = @JoinColumn(name = "A_ID"))
    @Enumerated(EnumType.STRING)
    private List<B> b;
}

public enum B {
TEST1,
TEST2,
TEST3
}

Can someone please help me

Upvotes: 1

Views: 410

Answers (2)

yrodiere
yrodiere

Reputation: 9977

@IndexedEmbedded does not make sense in your case, since it's supposed to embed fields from the target type, and your enum type does not define fields itself (e.g. via @FullTextField on its properties).

What you want is simply to define a field in your entity A:

@Entity
@Indexed
public class A {
    @KeywordField // Replace @IndexedEmbedded with this
    @ElementCollection
    @CollectionTable(name = "A_B", joinColumns = @JoinColumn(name = "A_ID"))
    @Enumerated(EnumType.STRING)
    private List<B> b;
}

public enum B {
TEST1,
TEST2,
TEST3
}

Upvotes: 1

tissa
tissa

Reputation: 396

@Entity
@Indexed
public class A {
    @GenericField
    @ElementCollection
    @CollectionTable(name = "A_B", joinColumns = @JoinColumn(name = "A_ID"))
    @Enumerated(EnumType.STRING)
    private List<B> b;
}

public enum B {
TEST1,
TEST2,
TEST3
}

b.should(f.match().field("b").matching(B.valueOf(keyWord)));

Upvotes: 0

Related Questions