Move solr field mappings for projects && add quotes
This commit is contained in:
parent
a8f3c1dd72
commit
80b3a1e7c2
|
@ -12,16 +12,10 @@ import java.util.Optional;
|
|||
@Mapper(componentModel = "spring")
|
||||
public interface ProjectRequestMapper {
|
||||
|
||||
Map<String, String> sortFieldMapping = Map.ofEntries(
|
||||
Map.entry("relevance", "score"),
|
||||
Map.entry("startDate", "projectstartyear"),
|
||||
Map.entry("endDate", "projectendyear")
|
||||
);
|
||||
|
||||
@Mapping(target = "start", expression = "java( calculateStart(src.getPage(), src.getPageSize()) )")
|
||||
@Mapping(target = "rows", source = "pageSize")
|
||||
@Mapping(target = "debugQuery", source = "debugQuery")
|
||||
@Mapping(target = "sort", expression = "java( eu.openaire.api.mappers.Utils.formatSortByParam(src.getSortBy(), sortFieldMapping) )")
|
||||
@Mapping(target = "sort", expression = "java( eu.openaire.api.mappers.Utils.formatSortByParam(src.getSortBy(), SolrFieldsMapper.projectSortMapping) )")
|
||||
SolrQueryParams toSolrQuery(ProjectRequest src);
|
||||
|
||||
@Named("calculateStart")
|
||||
|
@ -32,31 +26,7 @@ public interface ProjectRequestMapper {
|
|||
@AfterMapping
|
||||
default void paramsCustomMapping(ProjectRequest src, @MappingTarget SolrQueryParams solrQueryParams) {
|
||||
|
||||
final Map<String, String> solrFieldMapping = Map.ofEntries(
|
||||
// search field mapping
|
||||
Map.entry("search", "__all:(%s)"),
|
||||
Map.entry("title", "projecttitle:(%s)"),
|
||||
Map.entry("keywords", "projectkeywords:(%s)"),
|
||||
|
||||
// filter query field mapping
|
||||
Map.entry("id", "__indexrecordidentifier:(%s)"),
|
||||
Map.entry("code", "projectcode_nt:(%s)"),
|
||||
Map.entry("acronym", "projectacronym:(%s)"),
|
||||
Map.entry("fundingShortName", "fundershortname:(%s)"),
|
||||
Map.entry("fundingStreamId", "fundinglevel0_name:(%s) OR fundinglevel1_name:(%s) OR fundinglevel2_name:(%s)"),
|
||||
Map.entry("callIdentifier", "projectcallidentifier:(%s)"),
|
||||
|
||||
Map.entry("startDate", "projectstartdate:[%s TO %s]"),
|
||||
Map.entry("endDate", "projectenddate:[%s TO %s]"),
|
||||
|
||||
// filter by related entity fields
|
||||
Map.entry("relCommunityId", "communityid:(%s)"),
|
||||
Map.entry("relOrganizationCountryCode", "relorganizationcountryid:(%s)"),
|
||||
Map.entry("relOrganizationName", "relorganizationname: (%s) or relorganizationshortname: (%s)"),
|
||||
Map.entry("relOrganizationId", "relorganizationid:(%s)"),
|
||||
Map.entry("relCollectedFromDatasourceId", "collectedfromdatasourceid:(%s)")
|
||||
|
||||
);
|
||||
final Map<String, String> solrFieldMapping = SolrFieldsMapper.projectFieldMapping;
|
||||
|
||||
var qList = new ArrayList<String>();
|
||||
|
||||
|
@ -93,7 +63,7 @@ public interface ProjectRequestMapper {
|
|||
}
|
||||
|
||||
if (!Utils.isNullOrEmpty(src.getAcronym())) {
|
||||
fqList.add(String.format(solrFieldMapping.get("acronym"), Utils.escapeAndJoin(src.getAcronym(), "OR", false)));
|
||||
fqList.add(String.format(solrFieldMapping.get("acronym"), Utils.escapeAndJoin(src.getAcronym(), "OR", true)));
|
||||
}
|
||||
|
||||
if (!Utils.isNullOrEmpty(src.getFundingShortName())) {
|
||||
|
@ -101,12 +71,12 @@ public interface ProjectRequestMapper {
|
|||
}
|
||||
|
||||
if (!Utils.isNullOrEmpty(src.getFundingStreamId())) {
|
||||
String fundingStreamId = Utils.escapeAndJoin(src.getFundingStreamId(), "OR", false);
|
||||
String fundingStreamId = Utils.escapeAndJoin(src.getFundingStreamId(), "OR", true);
|
||||
fqList.add(String.format(solrFieldMapping.get("fundingStreamId"), fundingStreamId, fundingStreamId, fundingStreamId));
|
||||
}
|
||||
|
||||
if (!Utils.isNullOrEmpty(src.getCallIdentifier())) {
|
||||
fqList.add(String.format(solrFieldMapping.get("callIdentifier"), Utils.escapeAndJoin(src.getCallIdentifier(), "OR", false)));
|
||||
fqList.add(String.format(solrFieldMapping.get("callIdentifier"), Utils.escapeAndJoin(src.getCallIdentifier(), "OR", true)));
|
||||
}
|
||||
|
||||
// related entity fields
|
||||
|
|
|
@ -5,7 +5,7 @@ import java.util.Map;
|
|||
public class SolrFieldsMapper {
|
||||
|
||||
// mappings for the organization entity
|
||||
public static final Map<String, String> organizationFieldsMapping = Map.ofEntries(
|
||||
public static final Map<String, String> organizationFieldsMapping = java.util.Map.ofEntries(
|
||||
// search field mapping
|
||||
Map.entry("search", "__all:(%s)"),
|
||||
Map.entry("legalName", "organizationlegalname:(%s)"),
|
||||
|
@ -50,4 +50,38 @@ public class SolrFieldsMapper {
|
|||
Map.entry("relevance", "score")
|
||||
);
|
||||
|
||||
|
||||
// mappings for the project entity
|
||||
public static final Map<String, String> projectFieldMapping = Map.ofEntries(
|
||||
// search field mapping
|
||||
Map.entry("search", "__all:(%s)"),
|
||||
Map.entry("title", "projecttitle:(%s)"),
|
||||
Map.entry("keywords", "projectkeywords:(%s)"),
|
||||
|
||||
// filter query field mapping
|
||||
Map.entry("id", "__indexrecordidentifier:(%s)"),
|
||||
Map.entry("code", "projectcode_nt:(%s)"),
|
||||
Map.entry("acronym", "projectacronym:(%s)"),
|
||||
Map.entry("fundingShortName", "fundershortname:(%s)"),
|
||||
Map.entry("fundingStreamId", "fundinglevel0_name:(%s) OR fundinglevel1_name:(%s) OR fundinglevel2_name:(%s)"),
|
||||
Map.entry("callIdentifier", "projectcallidentifier:(%s)"),
|
||||
|
||||
Map.entry("startDate", "projectstartdate:[%s TO %s]"),
|
||||
Map.entry("endDate", "projectenddate:[%s TO %s]"),
|
||||
|
||||
// filter by related entity fields
|
||||
Map.entry("relCommunityId", "communityid:(%s)"),
|
||||
Map.entry("relOrganizationCountryCode", "relorganizationcountryid:(%s)"),
|
||||
Map.entry("relOrganizationName", "relorganizationname: (%s) OR relorganizationshortname: (%s)"),
|
||||
Map.entry("relOrganizationId", "relorganizationid:(%s)"),
|
||||
Map.entry("relCollectedFromDatasourceId", "collectedfromdatasourceid:(%s)")
|
||||
|
||||
);
|
||||
|
||||
public static final Map<String, String> projectSortMapping = Map.ofEntries(
|
||||
Map.entry("relevance", "score"),
|
||||
Map.entry("startDate", "projectstartyear"),
|
||||
Map.entry("endDate", "projectendyear")
|
||||
);
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue