diff --git a/src/main/java/eu/openaire/api/dto/request/ResearchProductsRequest.java b/src/main/java/eu/openaire/api/dto/request/ResearchProductsRequest.java index 3feaf56..ce2806f 100644 --- a/src/main/java/eu/openaire/api/dto/request/ResearchProductsRequest.java +++ b/src/main/java/eu/openaire/api/dto/request/ResearchProductsRequest.java @@ -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 here); 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 here); 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 here `[Only for publications]`", array = @ArraySchema(schema = @Schema(type = "string"))) // private String[] fos; diff --git a/src/main/java/eu/openaire/api/mappers/query/ResearchProductsRequestMapper.java b/src/main/java/eu/openaire/api/mappers/query/ResearchProductsRequestMapper.java index 9d3f71a..b8a23a5 100644 --- a/src/main/java/eu/openaire/api/mappers/query/ResearchProductsRequestMapper.java +++ b/src/main/java/eu/openaire/api/mappers/query/ResearchProductsRequestMapper.java @@ -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)));