Skip to content

Commit 57b7d75

Browse files
Temp fix for the search challenges
1 parent daeb03b commit 57b7d75

File tree

1 file changed

+6
-14
lines changed

1 file changed

+6
-14
lines changed

src/services/ChallengeService.js

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -172,26 +172,18 @@ async function searchChallenges (currentUser, criteria) {
172172
})
173173
}
174174

175-
const finalQuery = {
176-
bool: {}
177-
}
178-
179-
if (mustQuery.length > 0) {
180-
finalQuery.bool.must = { ...mustQuery }
181-
}
182-
183-
if (!_.isUndefined(mustNotQuery)) {
184-
// TODO: this is breaking the search functionality because of dirty data
185-
// finalQuery.bool.must_not = { ...mustNotQuery }
186-
}
187-
188175
const esQuery = {
189176
index: config.get('ES.ES_INDEX'),
190177
type: config.get('ES.ES_TYPE'),
191178
size: criteria.perPage,
192179
from: (criteria.page - 1) * criteria.perPage, // Es Index starts from 0
193180
body: {
194-
query: mustQuery.length > 0 || !_.isUndefined(mustNotQuery) ? finalQuery : {
181+
query: mustQuery.length > 0 || !_.isUndefined(mustNotQuery) ? {
182+
bool: {
183+
must: mustQuery,
184+
must_not: mustNotQuery
185+
}
186+
} : {
195187
match_all: {}
196188
},
197189
sort: [{ 'created': { 'order': 'asc', 'missing': '_last', 'unmapped_type': 'String' } }]

0 commit comments

Comments
 (0)