Caused by: org.hibernate.search.exception.SearchException: HSEARCH000299: @SortableField declared on xxx.entities.warehouse.Article#articleLabel references to undeclared field 'articleLabel'
I annotated:
@Transient
@Translated
@SortableField(forField = "articleLabel")
var articleLabel: String = ""
Blockquote
and tried to apply sorting that way:
val sort: Sort = qb
.sort()
.byField("articleLabel").andByScore() // Descending order
.createSort()
Could you please tell me what’s wrong with my code?
You have to create a specific sort field that uses a specific analyzer configuration based on a keyword tokenizer (which does not separate tokens and keep your string as is) and potentially additional filters such as lowercase and ASCII folding.
If you’re using a field that is tokenized, you will have unexpected results.