I am using Hibernate Search 6 configured to an elasticsearch backend.
@Indexed
public class Book extends PanacheEntity{
@FullTextField
public String title;
@GenericField
public Double price;
}
I can filter on the price field for books in a price range, as follows:
Search.session(entityManager)
.search(Book.class)
.predicate(f -> f.bool(b -> {
b.must(f.range().field("price").lessThan(50));
}));
I would like to be able to sort the search results by price as well. For this I changed the field definition to
@GenericField(sortable = Sortable.YES)
private Double price;
I am doing the sort as follows:
.sort(f -> f.composite(b -> {
b.add(f.field("price");
} ) )
I am getting the error as follows, which looks to have been thrown from Elastic
Can\u0027t load fielddata on [offer.price] because fielddata is unsupported on fields of type [double]. Use doc values instead.
I have seen Can you sort and search on same field with Hibernate/Lucene? but I dont see equivalent annotations in Hibernate search 6