Commit b3092b0d authored by Viacheslav Pavlov's avatar Viacheslav Pavlov

Suggestions for "images" accession filter

parent fb418b1b
......@@ -83,7 +83,7 @@ public class AccessionServiceImpl implements AccessionService {
public static final Logger LOG = LoggerFactory.getLogger(AccessionServiceImpl.class);
private final Set<String> suggestions = Sets.newHashSet("aegis", "crop.shortName", "institute.code", "taxonomy.genus", "taxonomy.genusSpecies", "taxonomy.species", "countryOfOrigin.code3", "historic", "sampStat", "available", "mlsStatus", "sgsv", "storage");
private final Set<String> suggestions = Sets.newHashSet("aegis", "crop.shortName", "institute.code", "taxonomy.genus", "taxonomy.genusSpecies", "taxonomy.species", "countryOfOrigin.code3", "historic", "sampStat", "available", "mlsStatus", "sgsv", "storage", "imageCount");
/** The accession repository. */
@Autowired
......@@ -516,6 +516,16 @@ public class AccessionServiceImpl implements AccessionService {
}
ElasticsearchService.TermResult suggestion = elasticsearchService.termStatisticsAuto(Accession.class, suggestionFilter, 100, suggestionKey);
ElasticsearchService.Term falseTerm = suggestion.getTerms().stream().filter((term) -> "0".equals(term.getTerm())).findFirst().orElse(new ElasticsearchService.Term("0", 0));
ElasticsearchService.Term trueTerm = new ElasticsearchService.Term("1", suggestion.getTotalCount() - falseTerm.getCount());
if ("imageCount".equals(suggestionKey)) {
ElasticsearchService.TermResult imageCountSuggestion = new ElasticsearchService.TermResult("images", suggestion.getTotal(), Lists.newArrayList(falseTerm, trueTerm), 0);
suggestionRes.put("images", imageCountSuggestion);
continue;
}
suggestionRes.put(suggestionKey, suggestion);
}
......
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