|
Hello
I am using hibernate-search version 5.3.0.Final. I use it for search value and sort result. I have defined my entities like this: Code:
@Entity
@Indexed
public class Film {
...
@Basic
@Fields( {
@Field,
@Field(name = "title_sort", analyze = Analyze.NO)
} )
@Column(name = "title")
public String getTitle() {
return title;
}
....
@ManyToOne
@IndexedEmbedded
@JoinTable(.......)
public Category getCategory() {
return category;
}
....
}
It's a basic use: entity with special sort field (title_sort) and manytoone attribute (category)
I want to detect invalid field when querying (with sort and search field): Code:
Query jpaQuery = queryBuilder
.keyword()
.wildcard()
.onField("title")
.matching(word)
.createQuery());
.......
org.hibernate.search.jpa.FullTextQuery jpaQuery = fullTextEntityManager.createFullTextQuery(globalQuery, className);
.......
SortField sortField = new SortField("title_sort", type, reverseSort);
Sort sort = new Sort(sortField);
jpaQuery.setSort(sort);
.......
List entityList = jpaQuery.getResultList();
For detecting invalid field (search and sort field): I catch exception NoSuchFieldException it works well for search field but for the sort field: the exception isn't fired
I have searched a lot in documentation but i haven't found details on this item. I think (maybe i am wrong) that is not normal that the engine accept invalid sort field.
regards
|