Add filter for sdgs

This commit is contained in:
Serafeim Chatzopoulos 2024-06-14 18:43:58 +03:00
parent d838a051c4
commit f9602e59c2
2 changed files with 12 additions and 11 deletions

View File

@ -80,11 +80,11 @@ public class ResearchProductsRequest {
private String[] citationCountClass;
// publication related filters
// @Parameter(description = "Retrieves publications classified with the respective Sustainable Development Goal number (for further information check <a href='https://sdgs.un.org/goals' target='_blank'>here</a>); the values for SDGs are numbers from 1 to 17 `[Only for publications]`", array = @ArraySchema(schema = @Schema(type = "integer")))
// // TODO: fix validation
//// @Min(value = 1)
//// @Max(value = 17)
// private Integer[] sdg;
@Parameter(description = "Retrieves publications classified with the respective Sustainable Development Goal number (for further information check <a href='https://sdgs.un.org/goals' target='_blank'>here</a>); the values for SDGs are numbers from 1 to 17 `[Only for publications]`", array = @ArraySchema(schema = @Schema(type = "integer")))
// TODO: fix validation
@Min(value = 1)
@Max(value = 17)
private Integer[] sdg;
//
// @Parameter(description = "Retrieves publications classified with the respective Field of Science classification value; for more information about the FOS classification values check <a href='https://graph.openaire.eu/docs/assets/files/athenarc_fos_hierarchy-3b6e1c7197e46bd3a3e9790115a8dec9.json' target='_blank'>here</a> `[Only for publications]`", array = @ArraySchema(schema = @Schema(type = "string")))
// private String[] fos;

View File

@ -240,12 +240,13 @@ public interface ResearchProductsRequestMapper {
fqList.add(String.format(solrFieldMapping.get("instanceType"), Utils.escapeAndJoin(src.getInstanceType(), "OR", false)));
}
// if (src.getSdg() != null) {
// String[] sdgValues = Arrays.stream(src.getSdg())
// .map(String::valueOf)
// .toArray(String[]::new);
// fqList.add(String.format(solrFieldMapping.get("sdg"), Utils.escapeAndJoin(sdgValues, "OR", false)));
// }
if (src.getSdg() != null) {
String[] sdgValues = Arrays.stream(src.getSdg())
.map(sdg -> sdg + ".*") // Append ".*" to match the sdg numeric prefix
.toArray(String[]::new);
fqList.add(String.format(solrFieldMapping.get("sdg"), String.join(" OR ", sdgValues)));
}
//
// if (!Utils.isNullOrEmpty(src.getFos())) {
// fqList.add(String.format(solrFieldMapping.get("fos"), Utils.escapeAndJoin(src.getFos(), "OR", false)));