Skip to content

Commit 33b8f7a

Browse files
ruai0511Peter Alfonsi
authored andcommitted
[Rule-based Auto-tagging] Bug fix on Update Rule API (opensearch-project#19497)
Signed-off-by: Ruirui Zhang <mariazrr@amazon.com>
1 parent d1ad6ca commit 33b8f7a

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
1414
- Add a toBuilder method in EngineConfig to support easy modification of configs([#19054](https://github.com/opensearch-project/OpenSearch/pull/19054))
1515
- Add StoreFactory plugin interface for custom Store implementations([#19091](https://github.com/opensearch-project/OpenSearch/pull/19091))
1616
- Use S3CrtClient for higher throughput while uploading files to S3 ([#18800](https://github.com/opensearch-project/OpenSearch/pull/18800))
17+
- [Rule-based Auto-tagging] bug fix on Update Rule API with multiple attributes ([#19497](https://github.com/opensearch-project/OpenSearch/pull/19497))
1718
- Add a dynamic setting to change skip_cache_factor and min_frequency for querycache ([#18351](https://github.com/opensearch-project/OpenSearch/issues/18351))
1819
- Add overload constructor for Translog to accept Channel Factory as a parameter ([#18918](https://github.com/opensearch-project/OpenSearch/pull/18918))
1920
- Add subdirectory-aware store module with recovery support ([#19132](https://github.com/opensearch-project/OpenSearch/pull/19132))

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,12 +105,16 @@ public static Optional<String> getDuplicateRuleId(Rule rule, List<Rule> ruleList
105105
*/
106106
public static Rule composeUpdatedRule(Rule originalRule, UpdateRuleRequest request, FeatureType featureType) {
107107
String requestDescription = request.getDescription();
108-
Map<Attribute, Set<String>> requestMap = request.getAttributeMap();
109108
String requestLabel = request.getFeatureValue();
109+
Map<Attribute, Set<String>> requestMap = request.getAttributeMap();
110+
Map<Attribute, Set<String>> updatedAttributeMap = new HashMap<>(originalRule.getAttributeMap());
111+
if (requestMap != null && !requestMap.isEmpty()) {
112+
updatedAttributeMap.putAll(requestMap);
113+
}
110114
return new Rule(
111115
originalRule.getId(),
112116
requestDescription == null ? originalRule.getDescription() : requestDescription,
113-
requestMap == null || requestMap.isEmpty() ? originalRule.getAttributeMap() : requestMap,
117+
updatedAttributeMap,
114118
featureType,
115119
requestLabel == null ? originalRule.getFeatureValue() : requestLabel,
116120
Instant.now().toString()

0 commit comments

Comments
 (0)