Sorting not working when update entity

I am using hibernate search 5.11 , i have added base entity below
@Column(updatable = false, name = “created_date”)
@Field(analyze = Analyze.NO,store = Store.NO)
private LocalDateTime createdDate;

and for sort
sort = queryBuilder
.byField(“createdDate”).desc() // Descending order
Sorting is working when I add new item but when I update this item sorting not working.
Note – Other entity extends this base entity.


We will need more information.

  • Be more specific about what you mean by “not working”: show some example data with the expected order vs. the actual order.
  • Be more specific about what you do when you “update items”: show the code that performs the actual update, in particular the properties that are modified.
  • Be more specific about the type involved; I understand there are two? Are both those types annotated with @Indexed?

… Also, this is a creation date, not a “last update” date, and the column in question is marked as “not updateable”, so I’m not sure what you mean by “when I update this item”. You probably confused this property with another one?


  1. Order should be in descending but i got
    “createdDate”:“2021-06-13 13:24:56”
    } ,
    “createdDate”:“2021-06-12 13:24:56”
    } ,
    “createdDate”:“2021-06-14 13:24:56” // this item details updated (createdDate not update)

  2. I update title for particular item (createdDate not update)

3 Yes both type are annotated with @Indexed

I am using base entity and extends this to other entity.
when I update I simply get information from db by id and update the title and then persist it.

Okay, I don’t know why you keep mentioning updates and why you keep not showing the code, but regardless the order seems wrong.

After you create the sort, do you add it to the query with query.setSort(sort);?

If so, and if it still doesn’t work, please enable logging of Elasticsearch requests by setting the log level of category to TRACE, then paste the log output when executing your search query here.

Please format this properly with ``` before and after the logs, like this:

``` logs...
...some more logs...

Please find details

public class Item extends BaseEntity{

Long id

private String title;


public class BaseEntity{

@Column(updatable = false, name = “created_date”)
@Field(analyze = Analyze.NO,store = Store.NO)
private LocalDateTime createdDate;

public Item updateItem(Long id,String title){

Optional item = itemRepository.findById(id);
if(item.isPresent()) {
return item;
throw new CustomException(“Item with id “+id+” not found”,HttpStatus.NOT_FOUND);
catch(Exection e){
throw new CustomException(“Something went wrong”,HttpStatus.INTERNAL_SERVER_ERROR,e.getMessage());


I will try to reproduce logs