Fix elastic dataset consistency (impacts memory)
This commit is contained in:
parent
c964af25b5
commit
bfbc271b56
|
@ -131,7 +131,7 @@ public class DatasetRepository extends ElasticRepository<Dataset, DatasetCriteri
|
||||||
criteria.getSortCriteria().forEach(sortCriteria -> {
|
criteria.getSortCriteria().forEach(sortCriteria -> {
|
||||||
switch(sortCriteria.getColumnType()) {
|
switch(sortCriteria.getColumnType()) {
|
||||||
case COLUMN:
|
case COLUMN:
|
||||||
sortBuilders.add(SortBuilders.fieldSort(sortCriteria.getFieldName()).order(SortOrder.fromString(sortCriteria.getOrderByType().name())));
|
sortBuilders.add(SortBuilders.fieldSort("datasets." + sortCriteria.getFieldName()).order(SortOrder.fromString(sortCriteria.getOrderByType().name())));
|
||||||
break;
|
break;
|
||||||
case JOIN_COLUMN:
|
case JOIN_COLUMN:
|
||||||
List<String> fields = Arrays.asList(sortCriteria.getFieldName().split(":"));
|
List<String> fields = Arrays.asList(sortCriteria.getFieldName().split(":"));
|
||||||
|
@ -145,10 +145,10 @@ public class DatasetRepository extends ElasticRepository<Dataset, DatasetCriteri
|
||||||
}
|
}
|
||||||
|
|
||||||
NestedQueryBuilder nestedQueryBuilder = QueryBuilders.nestedQuery("datasets", boolQuery, ScoreMode.Avg).innerHit(new InnerHitBuilder().setFetchSourceContext(new FetchSourceContext(true, new String[]{"datasets.tags"}, null)));
|
NestedQueryBuilder nestedQueryBuilder = QueryBuilders.nestedQuery("datasets", boolQuery, ScoreMode.Avg).innerHit(new InnerHitBuilder().setFetchSourceContext(new FetchSourceContext(true, new String[]{"datasets.tags"}, null)));
|
||||||
searchSourceBuilder.query(nestedQueryBuilder).from(criteria.getOffset()).fetchSource("datasets.tags", null);
|
searchSourceBuilder.query(nestedQueryBuilder)/*.from(criteria.getOffset())*/.fetchSource("datasets.tags", null);
|
||||||
if (criteria.getSize() > 0) {
|
/*if (criteria.getSize() > 0) {
|
||||||
searchSourceBuilder.size(criteria.getSize());
|
searchSourceBuilder.size(criteria.getSize());
|
||||||
}
|
}*/
|
||||||
sortBuilders.forEach(searchSourceBuilder::sort);
|
sortBuilders.forEach(searchSourceBuilder::sort);
|
||||||
searchRequest.source(searchSourceBuilder);
|
searchRequest.source(searchSourceBuilder);
|
||||||
SearchResponse response = this.getClient().search(searchRequest, RequestOptions.DEFAULT);
|
SearchResponse response = this.getClient().search(searchRequest, RequestOptions.DEFAULT);
|
||||||
|
@ -191,7 +191,7 @@ public class DatasetRepository extends ElasticRepository<Dataset, DatasetCriteri
|
||||||
criteria.getSortCriteria().forEach(sortCriteria -> {
|
criteria.getSortCriteria().forEach(sortCriteria -> {
|
||||||
switch(sortCriteria.getColumnType()) {
|
switch(sortCriteria.getColumnType()) {
|
||||||
case COLUMN:
|
case COLUMN:
|
||||||
sortBuilders.add(SortBuilders.fieldSort(sortCriteria.getFieldName()).order(SortOrder.fromString(sortCriteria.getOrderByType().name())));
|
sortBuilders.add(SortBuilders.fieldSort("datasets." + sortCriteria.getFieldName()).order(SortOrder.fromString(sortCriteria.getOrderByType().name())));
|
||||||
break;
|
break;
|
||||||
case JOIN_COLUMN:
|
case JOIN_COLUMN:
|
||||||
List<String> fields = Arrays.asList(sortCriteria.getFieldName().split(":"));
|
List<String> fields = Arrays.asList(sortCriteria.getFieldName().split(":"));
|
||||||
|
@ -205,7 +205,7 @@ public class DatasetRepository extends ElasticRepository<Dataset, DatasetCriteri
|
||||||
}
|
}
|
||||||
|
|
||||||
NestedQueryBuilder nestedQueryBuilder = QueryBuilders.nestedQuery("datasets", boolQuery, ScoreMode.None).innerHit(new InnerHitBuilder().setFetchSourceContext(new FetchSourceContext(true, new String[]{"datasets.id"}, null)));
|
NestedQueryBuilder nestedQueryBuilder = QueryBuilders.nestedQuery("datasets", boolQuery, ScoreMode.None).innerHit(new InnerHitBuilder().setFetchSourceContext(new FetchSourceContext(true, new String[]{"datasets.id"}, null)));
|
||||||
searchSourceBuilder.query(nestedQueryBuilder).from(criteria.getOffset()).size(criteria.getSize()).fetchSource("datasets.id", null);
|
searchSourceBuilder.query(nestedQueryBuilder)/*.from(criteria.getOffset()).size(criteria.getSize())*/.fetchSource("datasets.id", null);
|
||||||
sortBuilders.forEach(searchSourceBuilder::sort);
|
sortBuilders.forEach(searchSourceBuilder::sort);
|
||||||
searchRequest.source(searchSourceBuilder);
|
searchRequest.source(searchSourceBuilder);
|
||||||
SearchResponse response = this.getClient().search(searchRequest, RequestOptions.DEFAULT);
|
SearchResponse response = this.getClient().search(searchRequest, RequestOptions.DEFAULT);
|
||||||
|
|
Loading…
Reference in New Issue