[develop | DONE | CHANGED]: refineFieldResults.service.ts: Added method "getAllRefineFieldResultsByFieldName()" to get all values of a specific refine field (not just first 100) | In method "getRefineFieldResultsByFieldName()" changed key:string to keys:string[] to be able to define multiple fields to query for all their values - creted helper method "fieldIncludesAnyOfTheKeywords()".

This commit is contained in:
Konstantina Galouni 2023-11-24 11:44:23 +02:00
parent 1f872d2beb
commit ff34511a9c
1 changed files with 25 additions and 4 deletions

View File

@ -26,11 +26,32 @@ export class RefineFieldResultsService {
.pipe(map(res => [res['meta'].total, RefineResultsUtils.parse(res['refineResults'],fields, entityName)])); .pipe(map(res => [res['meta'].total, RefineResultsUtils.parse(res['refineResults'],fields, entityName)]));
} }
getRefineFieldResultsByFieldName(fieldName:string, entityName:string, properties:EnvProperties):any{
let key:string="fundinglevel";
let link = properties.searchAPIURLLAst +this.getSearchAPIURLForEntity(entityName)+"?fields="+fieldName +(fieldName.toString().indexOf(key)!=-1?('&sf='+fieldName):'')+ "&format=json";
return this.getField(link,fieldName, properties);
getAllRefineFieldResultsByFieldName(fieldName:string, entityName:string, properties:EnvProperties, refineQuery:string=null):any{
// let keys:string[]=["funder", "relfunder", "fundinglevel"];
let url = properties.searchAPIURLLAst +this.getSearchAPIURLForEntity(entityName)+"?fields="+fieldName +('&sf='+fieldName)+ "&format=json";
if(refineQuery!= null && refineQuery != '' ) {
url += refineQuery;
}
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
//.map(res => <any> res.json())
.pipe(map(res => [res['meta'].total, RefineResultsUtils.parse(res['refineResults'],[fieldName], entityName)]));
}
getRefineFieldResultsByFieldName(fieldName:string, entityName:string, properties:EnvProperties):any{
let keys:string[]=["fundinglevel"];
let link = properties.searchAPIURLLAst +this.getSearchAPIURLForEntity(entityName)+"?fields="+fieldName +(this.fieldIncludesAnyOfTheKeywords(fieldName, keys)?('&sf='+fieldName):'')+ "&format=json";
return this.getField(link,fieldName, properties);
}
fieldIncludesAnyOfTheKeywords(field: string, keywords: string[]) {
for(let keyword of keywords) {
if(field.toString().indexOf(keyword)!=-1) {
return true;
}
}
return false;
} }
getField (link:string,fieldName:string, properties:EnvProperties):any{ getField (link:string,fieldName:string, properties:EnvProperties):any{