@@ -273,7 +273,8 @@ async function searchChallenges (currentUser, criteria) {
273
273
should : [
274
274
{ wildcard : { name : `*${ criteria . search } *` } } ,
275
275
{ wildcard : { name : `${ criteria . search } *` } } ,
276
- { wildcard : { name : `*${ criteria . search } ` } }
276
+ { wildcard : { name : `*${ criteria . search } ` } } ,
277
+ { match_phrase : { tags : criteria . search } } ,
277
278
]
278
279
} } )
279
280
} else {
@@ -404,6 +405,10 @@ async function searchChallenges (currentUser, criteria) {
404
405
405
406
const groupsQuery = [ ]
406
407
408
+ if ( criteria . tco ) {
409
+ boolQuery . push ( { match_phrase_prefix : { 'events.key' : 'tco' } } )
410
+ }
411
+
407
412
if ( criteria . events ) {
408
413
boolQuery . push ( {
409
414
bool : {
@@ -662,14 +667,14 @@ async function searchChallenges (currentUser, criteria) {
662
667
}
663
668
}
664
669
665
- logger . debug ( `es Query ${ JSON . stringify ( esQuery ) } ` )
670
+ logger . debug ( `es Query ${ JSON . stringify ( esQuery , null , 4 ) } ` )
666
671
// Search with constructed query
667
672
let docs
668
673
try {
669
674
docs = await esClient . search ( esQuery )
670
675
} catch ( e ) {
671
676
// Catch error when the ES is fresh and has no data
672
- logger . error ( `Query Error from ES ${ JSON . stringify ( e ) } ` )
677
+ logger . error ( `Query Error from ES ${ JSON . stringify ( e , null , 4 ) } ` )
673
678
docs = {
674
679
hits : {
675
680
total : 0 ,
@@ -791,7 +796,8 @@ searchChallenges.schema = {
791
796
includeAllEvents : Joi . boolean ( ) . default ( true ) ,
792
797
useSchedulingAPI : Joi . boolean ( ) ,
793
798
totalPrizesFrom : Joi . number ( ) . min ( 0 ) ,
794
- totalPrizesTo : Joi . number ( ) . min ( 0 )
799
+ totalPrizesTo : Joi . number ( ) . min ( 0 ) ,
800
+ tco : Joi . boolean ( ) . default ( false )
795
801
} ) . unknown ( true )
796
802
}
797
803
0 commit comments