@@ -456,8 +456,7 @@ async function searchJobs (currentUser, criteria, options = { returnAll: false }
456456 query : {
457457 bool : {
458458 must : [ ] ,
459- filter : [ ] ,
460- should : [ ]
459+ filter : [ ]
461460 }
462461 } ,
463462 from : ( page - 1 ) * perPage ,
@@ -480,7 +479,8 @@ async function searchJobs (currentUser, criteria, options = { returnAll: false }
480479 'title' ,
481480 'status' ,
482481 'minSalary' ,
483- 'maxSalary'
482+ 'maxSalary' ,
483+ 'jobLocation'
484484 ] ) , ( value , key ) => {
485485 let must
486486 if ( key === 'description' || key === 'title' ) {
@@ -497,6 +497,12 @@ async function searchJobs (currentUser, criteria, options = { returnAll: false }
497497 [ `${ key } s` ] : [ value ]
498498 }
499499 }
500+ } else if ( key === 'jobLocation' && value && value . length > 0 ) {
501+ must = {
502+ wildcard : {
503+ [ key ] : `*${ value } *`
504+ }
505+ }
500506 } else if ( key === 'minSalary' || key === 'maxSalary' ) {
501507 const salaryOp = key === 'minSalary' ? 'gte' : 'lte'
502508 must = {
@@ -517,27 +523,6 @@ async function searchJobs (currentUser, criteria, options = { returnAll: false }
517523 }
518524 esQuery . body . query . bool . must . push ( must )
519525 } )
520- // If criteria contains jobLocation, filter jobLocation with this value
521- if ( criteria . jobLocation ) {
522- // filter out null value
523- esQuery . body . query . bool . should . push ( {
524- bool : {
525- must : [
526- {
527- exists : {
528- field : 'jobLocation'
529- }
530- }
531- ]
532- }
533- } )
534- // filter the jobLocation
535- esQuery . body . query . bool . should . push ( {
536- term : {
537- jobLocation : criteria . jobLocation
538- }
539- } )
540- }
541526 // If criteria contains projectIds, filter projectId with this value
542527 if ( criteria . projectIds ) {
543528 esQuery . body . query . bool . filter . push ( {
0 commit comments