Skip to content

Commit e99f7bd

Browse files
committed
revise based on comments
Signed-off-by: Ruirui Zhang <[email protected]>
1 parent 7a51365 commit e99f7bd

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

modules/autotagging-commons/common/src/main/java/org/opensearch/rule/RuleUtils.java

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@
3131
*/
3232
@ExperimentalApi
3333
public class RuleUtils {
34+
private static final String PIPE_DELIMITER = "\\|";
35+
private static final String DOT_DELIMITER = ".";
3436

3537
/**
3638
* constructor for RuleUtils
@@ -130,10 +132,10 @@ public static Map<String, Set<String>> buildAttributeFilters(Rule rule) {
130132
for (Map.Entry<Attribute, Set<String>> entry : rule.getAttributeMap().entrySet()) {
131133
Attribute attribute = entry.getKey();
132134
Set<String> values = entry.getValue();
133-
if (!attribute.getPrioritizedSubfields().isEmpty()) {
135+
if (hasSubfields(attribute)) {
134136
for (String value : values) {
135-
String[] parts = value.split("\\|");
136-
String topLevelAttribute = attribute.getName() + "." + parts[0];
137+
String[] parts = value.split(PIPE_DELIMITER);
138+
String topLevelAttribute = attribute.getName() + DOT_DELIMITER + parts[0];
137139
attributeFilters.computeIfAbsent(topLevelAttribute, k -> new HashSet<>()).add(parts[1]);
138140
}
139141
} else {
@@ -142,4 +144,8 @@ public static Map<String, Set<String>> buildAttributeFilters(Rule rule) {
142144
}
143145
return attributeFilters;
144146
}
147+
148+
private static boolean hasSubfields(Attribute attribute) {
149+
return !attribute.getPrioritizedSubfields().isEmpty();
150+
}
145151
}

modules/autotagging-commons/common/src/main/java/org/opensearch/rule/service/IndexStoredRulePersistenceService.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,7 @@ private void getRuleFromIndex(String id, QueryBuilder queryBuilder, String searc
231231
handleGetRuleResponse(hits, listener);
232232
} catch (Exception e) {
233233
if (e instanceof IndexNotFoundException) {
234+
logger.debug("Failed to get rule from index [{}]: index doesn't exist.", indexName);
234235
handleGetRuleResponse(new ArrayList<>(), listener);
235236
return;
236237
}

0 commit comments

Comments
 (0)