diff --git a/src/services/ChallengeService.js b/src/services/ChallengeService.js index 35f3d7d4..47616a6d 100644 --- a/src/services/ChallengeService.js +++ b/src/services/ChallengeService.js @@ -533,16 +533,12 @@ async function searchChallenges(currentUser, criteria) { mustNotQuery.push({ exists: { field: "groups" } }); } else if (!currentUser.isMachine && !_hasAdminRole) { // If the user is not M2M and is not an admin, return public + challenges from groups the user can access - _.each(accessibleGroups, (g) => { - groupsQuery.push({ match_phrase: { groups: g } }); - }); + groupsQuery.push({ terms: { "groups.keyword": accessibleGroups } }); // include public challenges groupsQuery.push({ bool: { must_not: { exists: { field: "groups" } } } }); } } else { - _.each(groupsToFilter, (g) => { - groupsQuery.push({ match_phrase: { groups: g } }); - }); + groupsQuery.push({ terms: { "groups.keyword": groupsToFilter } }); } if (criteria.ids) { @@ -2077,7 +2073,7 @@ updateChallenge.schema = { .unknown(true) ) .min(1), - tags: Joi.array().items(Joi.string().required()).min(1), // tag names + tags: Joi.array().items(Joi.string()), // tag names projectId: Joi.number().integer().positive(), legacyId: Joi.number().integer().positive(), constraints: Joi.object()