Commit a785e935 by apoorvnaik Committed by Madhan Neethiraj

ATLAS-2118: basic search fix - incorrect results for contains operator

parent 13fed7a9
......@@ -220,6 +220,8 @@ public abstract class SearchProcessor {
}
} else if (StringUtils.isNotEmpty(filterCriteria.getAttributeName())) {
try {
if (insideOrCondition && !isIndexSearchable(filterCriteria, structType)) {
ret = false;
}
......@@ -614,8 +616,34 @@ public abstract class SearchProcessor {
}
}
// ATLAS-2118: Reserved regex characters in attribute value can cause the graph query to fail when parsing the contains regex
private String getContainsRegex(String attributeValue) {
return ".*" + attributeValue + ".*";
StringBuilder escapedAttrVal = new StringBuilder(".*");
for (int i = 0; i < attributeValue.length(); i++) {
final char c = attributeValue.charAt(i);
switch (c) {
case '+':
case '|':
case '(':
case '{':
case '[':
case '*':
case '?':
case '$':
case '/':
case '^':
escapedAttrVal.append('\\');
break;
}
escapedAttrVal.append(c);
}
escapedAttrVal.append(".*");
return escapedAttrVal.toString();
}
private String getSuffixRegex(String attributeValue) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment