Commit c3a6d08d authored by Matija Obreza's avatar Matija Obreza
Browse files

Merge branch...

Merge branch 'ui-414-sort-by-filters-doesn-t-sort-content-if-user-user-full-text-query-filter' into 'master'

Fix: "Sort by" filters doesn`t sort content if user user "Full-text query" filter

Closes genesys-ui#414

See merge request genesys-pgr/genesys-server!429
parents a9e07d57 98f05391
......@@ -531,11 +531,14 @@ public class DatasetServiceImpl implements DatasetService {
public Page<Dataset> listDatasets(final DatasetFilter filter, final Pageable page) {
final BooleanBuilder published = new BooleanBuilder();
published.and(QDataset.dataset.state.eq(PublishState.PUBLISHED).and(QDataset.dataset.current.isTrue()));
Page<Dataset> res;
final Pageable markdownSortPageRequest = JPAUtils.toMarkdownSort(page, "title");
if (filter.isFulltextQuery()) {
return elasticsearchService.findAll(Dataset.class, filter, published, page);
res = elasticsearchService.findAll(Dataset.class, filter, published, markdownSortPageRequest);
} else {
res = datasetRepository.findAll(published.and(filter.buildPredicate()), markdownSortPageRequest);
}
final Pageable markdownSortPageRequest = JPAUtils.toMarkdownSort(page, "title");
final Page<Dataset> res = datasetRepository.findAll(published.and(filter.buildPredicate()), markdownSortPageRequest);
return new PageImpl<>(res.getContent(), page, res.getTotalElements());
}
......
......@@ -99,6 +99,7 @@ import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.data.elasticsearch.core.ElasticsearchTemplate;
import org.springframework.data.elasticsearch.core.query.AliasQuery;
import org.springframework.data.elasticsearch.core.query.FetchSourceFilter;
......@@ -109,7 +110,6 @@ import org.springframework.data.elasticsearch.core.query.SourceFilter;
import org.springframework.data.geo.Point;
import org.springframework.data.jpa.repository.support.Querydsl;
import org.springframework.data.querydsl.SimpleEntityPathResolver;
import org.springframework.scheduling.TaskScheduler;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.transaction.annotation.Transactional;
......@@ -951,13 +951,12 @@ public class ElasticsearchServiceImpl implements ElasticsearchService, Initializ
if (page.getOffset() > 100000) {
LOG.warn("Large offset={} for ES query", page.getOffset());
}
SearchRequestBuilder esQuery = client.prepareSearch(indexName).setTypes(COMMON_TYPE_NAME).setQuery(query)
.setFrom(page.getOffset()).setSize(page.getPageSize());
// for (Sort.Order order : page.getSort()) {
// esQuery.addSort(SortBuilders.fieldSort(order.getProperty()).order(SortOrder.valueOf(order.getDirection().name())));
// }
for (Sort.Order order : page.getSort()) {
esQuery.addSort(SortBuilders.fieldSort(order.getProperty()).order(SortOrder.valueOf(order.getDirection().name())));
}
SearchResponse searchResponse = esQuery.get();
List<T> content = new ArrayList<>();
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment