Skip to content
This repository was archived by the owner on Mar 13, 2025. It is now read-only.

Fixes u-bahn-app #487 #21

Merged
merged 1 commit into from
Jul 28, 2020
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
19 changes: 9 additions & 10 deletions src/common/es-helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -268,14 +268,14 @@ function getTotalCount (total) {
return typeof total === 'number' ? total : total.value
}

function escapeRegex(str) {
return str
.replace(/[\*\+\-=~><\"\?^\${}\(\)\:\!\/[\]\\\s]/g, '\\$&') // replace single character special characters
.replace(/\|\|/g, '\\||') // replace ||
.replace(/\&\&/g, '\\&&') // replace &&
.replace(/AND/g, '\\A\\N\\D') // replace AND
.replace(/OR/g, '\\O\\R') // replace OR
.replace(/NOT/g, '\\N\\O\\T'); // replace NOT
function escapeRegex (str) {
return str
.replace(/[\*\+\-=~><\"\?^\${}\(\)\:\!\/[\]\\\s]/g, '\\$&') // replace single character special characters
.replace(/\|\|/g, '\\||') // replace ||
.replace(/\&\&/g, '\\&&') // replace &&
.replace(/AND/g, '\\A\\N\\D') // replace AND
.replace(/OR/g, '\\O\\R') // replace OR
.replace(/NOT/g, '\\N\\O\\T') // replace NOT
}

async function getOrganizationId (handle) {
Expand Down Expand Up @@ -583,7 +583,6 @@ function setUserAttributesFiltersToEsQuery (filterClause, attributes) {
attribute.value = [attribute.value]
}


filterClause.push({
nested: {
path: USER_ATTRIBUTE.esDocumentPath,
Expand Down Expand Up @@ -660,7 +659,7 @@ async function setUserSearchClausesToEsQuery (boolClause, keyword) {
boolClause.should.push({
query_string: {
fields: ['firstName', 'lastName', 'handle'],
query: `*${keyword.replace(/ +/g, ' ').split(' ').join('* AND *')}*`
query: `*${keyword.replace(/ +/g, ' ').split(' ').join('* OR *')}*`
}
})

Expand Down