Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 9 additions & 24 deletions src/services/JobService.js
Original file line number Diff line number Diff line change
Expand Up @@ -456,8 +456,7 @@ async function searchJobs (currentUser, criteria, options = { returnAll: false }
query: {
bool: {
must: [],
filter: [],
should: []
filter: []
}
},
from: (page - 1) * perPage,
Expand All @@ -480,7 +479,8 @@ async function searchJobs (currentUser, criteria, options = { returnAll: false }
'title',
'status',
'minSalary',
'maxSalary'
'maxSalary',
'jobLocation'
]), (value, key) => {
let must
if (key === 'description' || key === 'title') {
Expand All @@ -497,6 +497,12 @@ async function searchJobs (currentUser, criteria, options = { returnAll: false }
[`${key}s`]: [value]
}
}
} else if (key === 'jobLocation' && value && value.length > 0) {
must = {
wildcard: {
[key]: `*${value}*`
}
}
} else if (key === 'minSalary' || key === 'maxSalary') {
const salaryOp = key === 'minSalary' ? 'gte' : 'lte'
must = {
Expand All @@ -517,27 +523,6 @@ async function searchJobs (currentUser, criteria, options = { returnAll: false }
}
esQuery.body.query.bool.must.push(must)
})
// If criteria contains jobLocation, filter jobLocation with this value
if (criteria.jobLocation) {
// filter out null value
esQuery.body.query.bool.should.push({
bool: {
must: [
{
exists: {
field: 'jobLocation'
}
}
]
}
})
// filter the jobLocation
esQuery.body.query.bool.should.push({
term: {
jobLocation: criteria.jobLocation
}
})
}
// If criteria contains projectIds, filter projectId with this value
if (criteria.projectIds) {
esQuery.body.query.bool.filter.push({
Expand Down