Skip to content

Commit 3e93356

Browse files
committed
fixing es query
1 parent fa915ce commit 3e93356

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/services/ResourceService.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,14 +52,15 @@ async function getResources (currentUser, challengeId, roleId, page, perPage) {
5252
page = page || 1
5353
perPage = perPage || config.DEFAULT_PAGE_SIZE
5454

55-
boolQuery.push({ match: { challengeId } })
55+
boolQuery.push({ match_phrase: { challengeId } })
5656

57+
// logger.warn('User Check')
5758
if (!currentUser || (!currentUser.isMachine && !helper.hasAdminRole(currentUser))) {
5859
// await checkAccess(currentUser, resources)
5960
// if not admin, and not machine, only return submitters
60-
boolQuery.push({ match: { roleId: config.SUBMITTER_RESOURCE_ROLE_ID } })
61+
boolQuery.push({ match_phrase: { roleId: config.SUBMITTER_RESOURCE_ROLE_ID } })
6162
} else if (roleId) {
62-
boolQuery.push({ match: { roleId } })
63+
boolQuery.push({ match_phrase: { roleId } })
6364
}
6465

6566
mustQuery.push({
@@ -83,7 +84,7 @@ async function getResources (currentUser, challengeId, roleId, page, perPage) {
8384
}
8485
const esClient = await helper.getESClient()
8586
let docs
86-
// logger.info(`ES Query ${JSON.stringify(esQuery)}`)
87+
logger.info(`ES Query ${JSON.stringify(esQuery)}`)
8788
try {
8889
docs = await esClient.search(esQuery)
8990
} catch (e) {
@@ -99,6 +100,7 @@ async function getResources (currentUser, challengeId, roleId, page, perPage) {
99100
}
100101
// Extract data from hits
101102
const resources = _.map(docs.hits.hits, item => item._source)
103+
// logger.warn('Resources extracted')
102104

103105
const memberIds = _.uniq(_.map(resources, r => r.memberId))
104106

0 commit comments

Comments
 (0)