@Override
public String getRouting() {
- return null;
+ return getRuleKeyAsString();
}
@Override
}
RuleKey getRuleKey() {
- return RuleKey.parse(getField(FIELD_ACTIVE_RULE_RULE_KEY));
+ return RuleKey.parse(getRuleKeyAsString());
+ }
+
+ private String getRuleKeyAsString() {
+ return getField(FIELD_ACTIVE_RULE_RULE_KEY);
}
String getRuleRepository() {
.filter(c -> c.getActiveRule() != null)
.forEach(c -> {
if (c.getType().equals(ActiveRuleChange.Type.DEACTIVATED)) {
- bulk.addDeletion(INDEX_TYPE_ACTIVE_RULE, String.valueOf(c.getActiveRule().getId()));
+ bulk.addDeletion(INDEX_TYPE_ACTIVE_RULE, String.valueOf(c.getActiveRule().getId()), c.getKey().getRuleKey().toString());
} else {
idsOfTouchedActiveRules.add(c.getActiveRule().getId());
}
}
private static IndexRequest newIndexRequest(ActiveRuleDoc doc) {
- return new IndexRequest(INDEX_TYPE_ACTIVE_RULE.getIndex(), INDEX_TYPE_ACTIVE_RULE.getType(), doc.getId())
+ return new IndexRequest(INDEX_TYPE_ACTIVE_RULE.getIndex(), INDEX_TYPE_ACTIVE_RULE.getType())
+ .id(doc.getId())
+ .routing(doc.getRouting())
.parent(doc.getRuleKey().toString())
.source(doc.getFields());
}
@Override
public String getRouting() {
- return null;
+ return keyAsString();
}
@Override
}
public RuleKey key() {
- return RuleKey.parse(this.getField(RuleIndexDefinition.FIELD_RULE_KEY));
+ return RuleKey.parse(keyAsString());
+ }
+
+ private String keyAsString() {
+ return getField(RuleIndexDefinition.FIELD_RULE_KEY);
}
public RuleDoc setKey(@Nullable String s) {
@Override
public String getRouting() {
- return null;
+ return getRuleKey().toString();
}
@Override
}
private static IndexRequest newIndexRequest(RuleDoc rule) {
- return new IndexRequest(INDEX_TYPE_RULE.getIndex(), INDEX_TYPE_RULE.getType(), rule.key().toString()).source(rule.getFields());
+ return new IndexRequest(INDEX_TYPE_RULE.getIndex(), INDEX_TYPE_RULE.getType())
+ .id(rule.getId())
+ .routing(rule.getRouting())
+ .source(rule.getFields());
}
private static IndexRequest newIndexRequest(RuleExtensionDoc ruleExtension) {
- return new IndexRequest(INDEX_TYPE_RULE_EXTENSION.getIndex(), INDEX_TYPE_RULE_EXTENSION.getType(), ruleExtension.getId())
+ return new IndexRequest(INDEX_TYPE_RULE_EXTENSION.getIndex(), INDEX_TYPE_RULE_EXTENSION.getType())
+ .id(ruleExtension.getId())
+ .routing(ruleExtension.getRouting())
.source(ruleExtension.getFields())
.parent(ruleExtension.getParent());
}