@@ -109,6 +109,15 @@ async function searchChallenges (currentUser, criteria) {
109
109
const page = criteria . page || 1
110
110
const perPage = criteria . perPage || 20
111
111
const boolQuery = [ ]
112
+ const matchPhraseKeys = [
113
+ 'id' ,
114
+ 'timelineTemplateId' ,
115
+ 'projectId' ,
116
+ 'legacyId' ,
117
+ 'status' ,
118
+ 'createdBy' ,
119
+ 'updatedBy'
120
+ ]
112
121
113
122
const includedTrackIds = _ . isArray ( criteria . trackIds ) ? criteria . trackIds : [ ]
114
123
@@ -151,18 +160,28 @@ async function searchChallenges (currentUser, criteria) {
151
160
includedTrackIds . push ( criteria . trackId )
152
161
}
153
162
154
- _ . forIn ( _ . omit ( criteria , [ 'types' , 'tracks' , 'typeIds' , 'trackIds' , 'type' , 'name' , 'trackId' , 'typeId' , 'description' , 'page' , 'perPage' , 'tag' ,
155
- 'group' , 'groups' , 'memberId' , 'ids' , 'createdDateStart' , 'createdDateEnd' , 'updatedDateStart' , 'updatedDateEnd' , 'startDateStart' , 'startDateEnd' , 'endDateStart' , 'endDateEnd' ,
156
- 'tags' , 'registrationStartDateStart' , 'registrationStartDateEnd' , 'currentPhaseName' , 'submissionStartDateStart' , 'submissionStartDateEnd' ,
157
- 'registrationEndDateStart' , 'registrationEndDateEnd' , 'submissionEndDateStart' , 'submissionEndDateEnd' , 'includeAllEvents' , 'events' ,
158
- 'forumId' , 'track' , 'reviewType' , 'confidentialityType' , 'directProjectId' , 'sortBy' , 'sortOrder' , 'isLightweight' , 'isTask' , 'taskIsAssigned' , 'taskMemberId' ] ) , ( value , key ) => {
163
+ _ . forIn ( _ . pick ( criteria , matchPhraseKeys ) , ( value , key ) => {
159
164
if ( ! _ . isUndefined ( value ) ) {
160
165
const filter = { match_phrase : { } }
161
166
filter . match_phrase [ key ] = value
162
167
boolQuery . push ( filter )
163
168
}
164
169
} )
165
170
171
+ _ . forEach ( _ . keys ( criteria ) , ( key ) => {
172
+ if ( _ . toString ( key ) . indexOf ( 'meta.' ) > - 1 ) {
173
+ // Parse and use metadata key
174
+ if ( ! _ . isUndefined ( criteria [ key ] ) ) {
175
+ const metaKey = key . split ( 'meta.' ) [ 1 ]
176
+ const metaMustQuery = { must : [
177
+ { match_phrase : { 'metadata.name' : metaKey } } ,
178
+ { match_phrase : { 'metadata.value' : criteria [ key ] } }
179
+ ] }
180
+ boolQuery . push ( metaMustQuery )
181
+ }
182
+ }
183
+ } )
184
+
166
185
if ( includedTypeIds . length > 0 ) {
167
186
boolQuery . push ( {
168
187
bool : {
@@ -594,7 +613,7 @@ searchChallenges.schema = {
594
613
taskMemberId : Joi . string ( ) ,
595
614
events : Joi . array ( ) . items ( Joi . number ( ) ) ,
596
615
includeAllEvents : Joi . boolean ( ) . default ( true )
597
- } )
616
+ } ) . unknown ( true )
598
617
}
599
618
600
619
/**
0 commit comments