@KeywordField on enum with Hibernate Search 6

@KeywordField is supposed to be used with String type only.
Does it work with enum annotated with EnumType.STRING?

P.S. I would test it if I could but my project is on Hibernate Search 5 and now I have 192 errors not solved while trying to migrate to Hibernate Search 6 and there is no way to compile it and run it.

P.P.S. Now I have 30 errors and BooleanJunction usage to convert to something else. Still don’t know what to do with this enum.

public enum ObjectStatus {
    ENABLED, DISABLED;
}

@KeywordField(
	projectable = Projectable.NO,
	searchable = Searchable.YES,
	sortable = Sortable.YES
)
@Enumerated(EnumType.STRING)
private ObjectStatus objectStatus;

With index fields of type String. Your entity property can be of any type: as long as you use a value bridge to convert your entity property to a String, it will work.

The default value bridge for enums converts them to strings, so yes it does.

The annotation with EnumType.STRING does not matter.

1 Like

Well, now that you wrote “index fields” it’s more clear to me. Java class property is property, not field so I should get it on my own but I did not.
Thank you very much!
The only really big thing left in my project is to convert BooleanJunctions to new logic and I can guess you can expect more questions from me LOL

Thanks!!