Skip to content
This repository was archived by the owner on Mar 13, 2025. It is now read-only.
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
6 changes: 3 additions & 3 deletions src/common/es-helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -630,7 +630,7 @@ function hasNonAlphaNumeric (text) {
*/
async function searchSkills (keyword) {
const queryDoc = DOCUMENTS.skill

keyword = escapeRegex(keyword)
const query = hasNonAlphaNumeric(keyword) ? `\\*${keyword}\\*` : `*${keyword}*`

const esQuery = {
Expand All @@ -655,14 +655,14 @@ async function searchSkills (keyword) {

async function setUserSearchClausesToEsQuery (boolClause, keyword) {
const skillIds = await searchSkills(keyword)

boolClause.should.push({
query_string: {
fields: ['firstName', 'lastName', 'handle'],
query: `*${keyword.replace(/ +/g, ' ').split(' ').join('* OR *')}*`
query: `\\*${escapeRegex(keyword.replace(/ +/g, ' ')).split(' ').join('\\* OR \\*')}\\*`
}
})

keyword = escapeRegex(keyword)
boolClause.should.push({
nested: {
path: USER_ATTRIBUTE.esDocumentPath,
Expand Down