Skip to content

Commit a0a8ab5

Browse files
jobLocation added
1 parent 697ed46 commit a0a8ab5

File tree

1 file changed

+25
-4
lines changed

1 file changed

+25
-4
lines changed

src/services/JobService.js

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -444,7 +444,8 @@ async function searchJobs (currentUser, criteria, options = { returnAll: false }
444444
query: {
445445
bool: {
446446
must: [],
447-
filter: []
447+
filter: [],
448+
should: []
448449
}
449450
},
450451
from: (page - 1) * perPage,
@@ -467,11 +468,10 @@ async function searchJobs (currentUser, criteria, options = { returnAll: false }
467468
'title',
468469
'status',
469470
'minSalary',
470-
'maxSalary',
471-
'jobLocation'
471+
'maxSalary'
472472
]), (value, key) => {
473473
let must
474-
if (key === 'description' || key === 'title' || key === 'jobLocation') {
474+
if (key === 'description' || key === 'title') {
475475
must = {
476476
match: {
477477
[key]: {
@@ -505,6 +505,27 @@ async function searchJobs (currentUser, criteria, options = { returnAll: false }
505505
}
506506
esQuery.body.query.bool.must.push(must)
507507
})
508+
// If criteria contains jobLocation, filter jobLocation with this value
509+
if (criteria.jobLocation) {
510+
// filter out null value
511+
esQuery.body.query.bool.should.push({
512+
bool: {
513+
must: [
514+
{
515+
exists: {
516+
field: 'jobLocation'
517+
}
518+
}
519+
]
520+
}
521+
})
522+
// filter the jobLocation
523+
esQuery.body.query.bool.should.push({
524+
term: {
525+
jobLocation: criteria.jobLocation
526+
}
527+
})
528+
}
508529
// If criteria contains projectIds, filter projectId with this value
509530
if (criteria.projectIds) {
510531
esQuery.body.query.bool.filter.push({

0 commit comments

Comments
 (0)