Skip to content

Fix issue: #556 #558

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 24, 2021
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