@@ -456,8 +456,7 @@ async function searchJobs (currentUser, criteria, options = { returnAll: false }
456
456
query : {
457
457
bool : {
458
458
must : [ ] ,
459
- filter : [ ] ,
460
- should : [ ]
459
+ filter : [ ]
461
460
}
462
461
} ,
463
462
from : ( page - 1 ) * perPage ,
@@ -480,7 +479,8 @@ async function searchJobs (currentUser, criteria, options = { returnAll: false }
480
479
'title' ,
481
480
'status' ,
482
481
'minSalary' ,
483
- 'maxSalary'
482
+ 'maxSalary' ,
483
+ 'jobLocation'
484
484
] ) , ( value , key ) => {
485
485
let must
486
486
if ( key === 'description' || key === 'title' ) {
@@ -497,6 +497,12 @@ async function searchJobs (currentUser, criteria, options = { returnAll: false }
497
497
[ `${ key } s` ] : [ value ]
498
498
}
499
499
}
500
+ } else if ( key === 'jobLocation' && value && value . length > 0 ) {
501
+ must = {
502
+ wildcard : {
503
+ [ key ] : `*${ value } *`
504
+ }
505
+ }
500
506
} else if ( key === 'minSalary' || key === 'maxSalary' ) {
501
507
const salaryOp = key === 'minSalary' ? 'gte' : 'lte'
502
508
must = {
@@ -517,27 +523,6 @@ async function searchJobs (currentUser, criteria, options = { returnAll: false }
517
523
}
518
524
esQuery . body . query . bool . must . push ( must )
519
525
} )
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
- }
541
526
// If criteria contains projectIds, filter projectId with this value
542
527
if ( criteria . projectIds ) {
543
528
esQuery . body . query . bool . filter . push ( {
0 commit comments