blossom-project / blossom

Blossom is a Java framework based on Spring-Boot which enables you to realize your projects quickly and smoothly. It comes with several modules and tools made to ease and speed up your development process.
http://blossom-project.com
Apache License 2.0
21 stars 21 forks source link

[SearchEngine] Extract the elasticsearch order computing from pageable sort to another overridable method #235

Open jtreillard opened 3 years ago

jtreillard commented 3 years ago

The ElasticSearch search sort is computed in method SearchEngineImpl.prepareSearch :

Sort sort = pageable.getSort();
    if (sort != null) {
      for (Order order : pageable.getSort()) {
        SortBuilder sortBuilder = SortBuilders.fieldSort("dto." + order.getProperty())
          .order(SortOrder.valueOf(order.getDirection().name()));
        searchRequest.addSort(sortBuilder);
      }
      searchRequest.addSort(SortBuilders.scoreSort());
    }

With this computing, you can only sort by DTO fields. If the indexing has been adapted to index additional fields external to the DTO, it is not possible to use them for sorting without overriding the whole prepareSearch method.

TODO : Extract the order computing in an overridable method