Commit 61ffc2c5 authored by Gradl, Tobias's avatar Gradl, Tobias
Browse files

Merge branch 'v4.x-master' into 'v5.x-master'

443: Fix ES exception [type=illegal_argument_exception, reason=maxSize

See merge request !37
parents a801ebf9 c33b64bc
Pipeline #26267 passed with stage
in 37 seconds
......@@ -50,10 +50,13 @@ public class QueryExecutionServiceImpl extends BaseQueryService implements Query
public static final String WORDCLOUD_ANALYZER = "Wordcloud";
public static final int WORDCLOUD_TERM_COUNT = 100;
// Collections that show numbers of document count in UI
public static final int COLLECTION_AGGREGATION_COUNT = 50;
@Autowired private JsonNodeHelper jsonNodeHelper;
@Autowired private FilterConverter filterConverter;
@Autowired protected ObjectMapper objMapper;
@Value("${querying.min_score:0.02F}")
private float minScoreThreshold;
......@@ -132,17 +135,17 @@ public class QueryExecutionServiceImpl extends BaseQueryService implements Query
private AggregationBuilder[] handleAggregationKey(String aggregation, String[] schemaIds) {
if (aggregation.equals(Constants.ELEMENT_KEY_COLLECTION_ID)) {
return new AggregationBuilder[] { AggregationBuilders.terms("datasources").field(Constants.ELEMENT_KEY_COLLECTION_ID).size(Integer.MAX_VALUE) };
return new AggregationBuilder[] { AggregationBuilders.terms("datasources").field(Constants.ELEMENT_KEY_COLLECTION_ID).size(COLLECTION_AGGREGATION_COUNT) };
} else if (aggregation.equals(WORDCLOUD_ANALYZER)) {
List<String> wordcloudFields;
List<AggregationBuilder> aggregations = new ArrayList<AggregationBuilder>();
List<AggregationBuilder> aggregations = new ArrayList<>();
ExtendedDatamodelContainer sc;
if (schemaIds==null) {
schemaIds = datamodelService.findAllSchemaIds().toArray(new String[0]);
}
List<String> aggregationFields = new ArrayList<String>();
List<String> aggregationFields = new ArrayList<>();
for (int i=0; i<schemaIds.length; i++) {
sc = datamodelService.findById(schemaIds[i]);
......@@ -173,7 +176,7 @@ public class QueryExecutionServiceImpl extends BaseQueryService implements Query
private List<String> renderExecutedQueries(Map<QueryBuilder, String[]> queryIndexMap) {
List<String> executedQueries = new ArrayList<String>();
List<String> executedQueries = new ArrayList<>();
for (QueryBuilder qBldr : queryIndexMap.keySet()) {
executedQueries.add(qBldr.toString());
}
......@@ -186,7 +189,7 @@ public class QueryExecutionServiceImpl extends BaseQueryService implements Query
protected QueryResult buildQueryResult(Query q, List<SearchResponse> responses, Locale locale) {
QueryResult qr = new QueryResult();
qr.setResultType(SearchTypes.REGULAR);
qr.setResultElements(new ArrayList<ResultElement>());
qr.setResultElements(new ArrayList<>());
for (SearchResponse resp : responses) {
if (resp==null) {
......
......@@ -34,7 +34,7 @@ import eu.dariah.de.search.transformation.base.MappingConfigurationContainer;
@Component
public class FilterServiceImpl implements FilterService {
protected static final Logger logger = LoggerFactory.getLogger(FilterServiceImpl.class);
@Autowired private DatamodelService datamodelService;
@Autowired private SearchService searchService;
@Autowired private MappingGenerationService mappingGenerationService;
......@@ -80,28 +80,30 @@ public class FilterServiceImpl implements FilterService {
continue;
}
for (Filter f : modeledFilters) {
for (String type : f.getFilterTypes()) {
if (agg.getName().startsWith(this.getFilterName(f, type))) {
terms = new ArrayList<>();
f.setTotalSize(f.getTotalSize() + ((MultiBucketsAggregation)agg).getBuckets().size());
for (MultiBucketsAggregation.Bucket b : ((MultiBucketsAggregation)agg).getBuckets()) {
term = new FilterTerm();
term.setTerm(b.getKeyAsString());
term.setCount(b.getDocCount());
term.setType(type);
terms.add(term);
if (terms.size()>=maxTermsPerFilterList) {
break;
if (modeledFilters!=null) {
for (Filter f : modeledFilters) {
if (f.getFilterTypes()!=null) {
for (String type : f.getFilterTypes()) {
if (agg.getName().startsWith(this.getFilterName(f, type))) {
terms = new ArrayList<>();
f.setTotalSize(f.getTotalSize() + ((MultiBucketsAggregation)agg).getBuckets().size());
for (MultiBucketsAggregation.Bucket b : ((MultiBucketsAggregation)agg).getBuckets()) {
term = new FilterTerm();
term.setTerm(b.getKeyAsString());
term.setCount(b.getDocCount());
term.setType(type);
terms.add(term);
if (terms.size()>=maxTermsPerFilterList) {
break;
}
}
if (!terms.isEmpty()) {
f.setTerms(terms);
availableFilters.add(f);
}
}
}
if (!terms.isEmpty()) {
f.setTerms(terms);
availableFilters.add(f);
}
}
}
......@@ -126,7 +128,7 @@ public class FilterServiceImpl implements FilterService {
for (String type : f.getFilterTypes()) {
aggs.add(AggregationBuilders.terms(this.getFilterName(f, type))
.field(this.getFilterPath(type, f.getLabel()))
.size(Integer.MAX_VALUE));
.size(maxTermsPerFilterList));
}
}
return aggs;
......
Markdown is supported
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