@@ -273,7 +273,8 @@ async function searchChallenges (currentUser, criteria) {
273273 should : [
274274 { wildcard : { name : `*${ criteria . search } *` } } ,
275275 { wildcard : { name : `${ criteria . search } *` } } ,
276- { wildcard : { name : `*${ criteria . search } ` } }
276+ { wildcard : { name : `*${ criteria . search } ` } } ,
277+ { match_phrase : { tags : criteria . search } } ,
277278 ]
278279 } } )
279280 } else {
@@ -404,6 +405,10 @@ async function searchChallenges (currentUser, criteria) {
404405
405406 const groupsQuery = [ ]
406407
408+ if ( criteria . tco ) {
409+ boolQuery . push ( { match_phrase_prefix : { 'events.key' : 'tco' } } )
410+ }
411+
407412 if ( criteria . events ) {
408413 boolQuery . push ( {
409414 bool : {
@@ -662,14 +667,14 @@ async function searchChallenges (currentUser, criteria) {
662667 }
663668 }
664669
665- logger . debug ( `es Query ${ JSON . stringify ( esQuery ) } ` )
670+ logger . debug ( `es Query ${ JSON . stringify ( esQuery , null , 4 ) } ` )
666671 // Search with constructed query
667672 let docs
668673 try {
669674 docs = await esClient . search ( esQuery )
670675 } catch ( e ) {
671676 // 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 ) } ` )
673678 docs = {
674679 hits : {
675680 total : 0 ,
@@ -791,7 +796,8 @@ searchChallenges.schema = {
791796 includeAllEvents : Joi . boolean ( ) . default ( true ) ,
792797 useSchedulingAPI : Joi . boolean ( ) ,
793798 totalPrizesFrom : Joi . number ( ) . min ( 0 ) ,
794- totalPrizesTo : Joi . number ( ) . min ( 0 )
799+ totalPrizesTo : Joi . number ( ) . min ( 0 ) ,
800+ tco : Joi . boolean ( ) . default ( false )
795801 } ) . unknown ( true )
796802}
797803
0 commit comments