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

Commit e4dc8b8

Browse files
topcoder-archive/topcoder-platform-u-bahn-app#295 - Fix issue where special chars in a query would not return results
1 parent 6f18893 commit e4dc8b8

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/common/es-helper.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -584,6 +584,12 @@ function setUserAttributesFiltersToEsQuery (filterClause, attributes) {
584584
}
585585
}],
586586
should: attribute.value.map(val => {
587+
val = val
588+
.replace(/ +/g, ' ')
589+
.split(' ')
590+
.map(word => word.replace(/[^a-zA-Z]/g, c => `${!isRegexReserved(c) ? c : '\\' + c}`))
591+
.join('* AND *')
592+
587593
return {
588594
query_string: {
589595
default_field: `${[USER_ATTRIBUTE.esDocumentValueStringQuery]}`,
@@ -711,7 +717,7 @@ function buildEsQueryFromFilter (filter) {
711717
* @param {*} char the char to check
712718
*/
713719
function isRegexReserved (char) {
714-
const reserved = '[^$.|?*+(){}\\'
720+
const reserved = '+-=&|!(){}[]^"~*?:\\/'
715721
return reserved.indexOf(char) !== -1
716722
}
717723

0 commit comments

Comments
 (0)