From 3d93cf19cde2ee5e856a8df53c1fbc0d01d7aaad Mon Sep 17 00:00:00 2001 From: Ben Kalmus Date: Tue, 30 Sep 2025 09:28:54 +0100 Subject: [PATCH 1/7] add deduplication field --- .../components/CompositionBehavior.yml | 22 ++++++ .../requests/composition/putComposition.json | 79 ++++++++++++++++++- 2 files changed, 98 insertions(+), 3 deletions(-) diff --git a/specs/composition/common/schemas/components/CompositionBehavior.yml b/specs/composition/common/schemas/components/CompositionBehavior.yml index f41bea4bc76..016bd8374ab 100644 --- a/specs/composition/common/schemas/components/CompositionBehavior.yml +++ b/specs/composition/common/schemas/components/CompositionBehavior.yml @@ -41,6 +41,14 @@ compositionBehavior: maxItems: 2 items: $ref: '#/injectedItem' + deduplication: + title: deduplication + type: object + additionalProperties: false + description: Deduplication configures the method used to remove the same items from injected groups and main search. + properties: + positioning: + $ref: '#/dedupPositioning' required: - main required: @@ -91,3 +99,17 @@ injectedItemSource: oneOf: - $ref: './InjectionSource.yml#/SearchSource' - $ref: './InjectionSource.yml#/ExternalSource' + +dedupPositioning: + type: string + enum: + - highest + - highestInjected + description: | + Deduplication setting to determine duplicate object resolution. + highest: + - Will keep the item in the highest position if a duplicate is found. + highestInjected: + - Keeps the item at its highest possible injected position, even if main might be higher. + example: highest + default: highestInjected diff --git a/tests/CTS/requests/composition/putComposition.json b/tests/CTS/requests/composition/putComposition.json index f2fb892eb29..7cc586ed99f 100644 --- a/tests/CTS/requests/composition/putComposition.json +++ b/tests/CTS/requests/composition/putComposition.json @@ -134,9 +134,7 @@ } }, { - "skipLanguages": [ - "kotlin" - ], + "skipLanguages": ["kotlin"], "parameters": { "compositionID": "my-metadata-compo", "composition": { @@ -288,5 +286,80 @@ } } } + }, + { + "parameters": { + "compositionID": "my-compo", + "composition": { + "objectID": "my-compo", + "name": "my composition", + "behavior": { + "injection": { + "main": { + "source": { + "search": { + "index": "foo", + "params": { + "filters": "brand:adidas" + } + } + } + }, + "injectedItems": [ + { + "key": "injectedItem1", + "source": { + "search": { + "index": "foo" + } + }, + "position": 2, + "length": 1 + } + ], + "deduplication": { + "positioning": "highest" + } + } + } + } + }, + "request": { + "path": "/1/compositions/my-compo", + "method": "PUT", + "body": { + "objectID": "my-compo", + "name": "my composition", + "behavior": { + "injection": { + "main": { + "source": { + "search": { + "index": "foo", + "params": { + "filters": "brand:adidas" + } + } + } + }, + "injectedItems": [ + { + "key": "injectedItem1", + "source": { + "search": { + "index": "foo" + } + }, + "position": 2, + "length": 1 + } + ], + "deduplication": { + "positioning": "highest" + } + } + } + } + } } ] From e3cc3d5b3f5e5aa28a0fffef775d094677d9b87d Mon Sep 17 00:00:00 2001 From: Ben Kalmus Date: Tue, 30 Sep 2025 09:50:48 +0100 Subject: [PATCH 2/7] add comp rule test --- .../composition/putCompositionRule.json | 102 ++++++++++++++++-- 1 file changed, 91 insertions(+), 11 deletions(-) diff --git a/tests/CTS/requests/composition/putCompositionRule.json b/tests/CTS/requests/composition/putCompositionRule.json index b27b2478f0c..98c37a2a8f8 100644 --- a/tests/CTS/requests/composition/putCompositionRule.json +++ b/tests/CTS/requests/composition/putCompositionRule.json @@ -78,9 +78,7 @@ } }, { - "skipLanguages": [ - "kotlin" - ], + "skipLanguages": ["kotlin"], "parameters": { "compositionID": "compositionID", "objectID": "rule-with-metadata", @@ -197,10 +195,7 @@ "compositionRule": { "objectID": "rule-with-exernal-source", "description": "my description", - "tags": [ - "tag1", - "tag2" - ], + "tags": ["tag1", "tag2"], "enabled": true, "validity": [ { @@ -258,10 +253,7 @@ "body": { "objectID": "rule-with-exernal-source", "description": "my description", - "tags": [ - "tag1", - "tag2" - ], + "tags": ["tag1", "tag2"], "enabled": true, "validity": [ { @@ -313,5 +305,93 @@ } } } + }, + { + "parameters": { + "compositionID": "compositionID", + "objectID": "rule-with-deduplication", + "compositionRule": { + "objectID": "rule-with-deduplication", + "description": "my description", + "enabled": true, + "conditions": [ + { + "anchoring": "contains", + "pattern": "harry" + } + ], + "consequence": { + "behavior": { + "injection": { + "main": { + "source": { + "search": { + "index": "my-index" + } + } + }, + "injectedItems": [ + { + "key": "injectedItem", + "source": { + "search": { + "index": "my-index" + } + }, + "position": 0, + "length": 3 + } + ], + "deduplication": { + "positioning": "highestInjected" + } + } + } + } + } + }, + "request": { + "path": "/1/compositions/compositionID/rules/rule-with-deduplication", + "method": "PUT", + "body": { + "objectID": "rule-with-deduplication", + "description": "my description", + "enabled": true, + "conditions": [ + { + "anchoring": "contains", + "pattern": "harry" + } + ], + "consequence": { + "behavior": { + "injection": { + "main": { + "source": { + "search": { + "index": "my-index" + } + } + }, + "injectedItems": [ + { + "key": "injectedItem", + "source": { + "search": { + "index": "my-index" + } + }, + "position": 0, + "length": 3 + } + ], + "deduplication": { + "positioning": "highestInjected" + } + } + } + } + } + } } ] From 7f1c198e630b9707b0e83bee2c4cfc4c10396f49 Mon Sep 17 00:00:00 2001 From: Ben Kalmus Date: Tue, 30 Sep 2025 11:12:11 +0100 Subject: [PATCH 3/7] improve setting description --- .../schemas/components/CompositionBehavior.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/specs/composition/common/schemas/components/CompositionBehavior.yml b/specs/composition/common/schemas/components/CompositionBehavior.yml index 016bd8374ab..86046e5f5f1 100644 --- a/specs/composition/common/schemas/components/CompositionBehavior.yml +++ b/specs/composition/common/schemas/components/CompositionBehavior.yml @@ -45,7 +45,7 @@ compositionBehavior: title: deduplication type: object additionalProperties: false - description: Deduplication configures the method used to remove the same items from injected groups and main search. + description: Deduplication configures the methods used to resolve duplicate items between main search results and injected group results. properties: positioning: $ref: '#/dedupPositioning' @@ -106,10 +106,10 @@ dedupPositioning: - highest - highestInjected description: | - Deduplication setting to determine duplicate object resolution. - highest: - - Will keep the item in the highest position if a duplicate is found. - highestInjected: - - Keeps the item at its highest possible injected position, even if main might be higher. + Deduplication positioning configures how a duplicate result should be resolved between an injected item and main search results. + Current configuration supports: + - 'highest': always select the item in the highest position, and remove duplicates that appear lower in the results. + - 'highestInjected': duplicate result will be moved to its highest possible injected position, but not higher. + If a duplicate appears higher in main search results, it will be removed to stay it's intended group position (which could be lower than main). example: highest default: highestInjected From 0ea81d5a97e2a194fa9985e72ba4b64c4277e0df Mon Sep 17 00:00:00 2001 From: Ben Kalmus Date: Tue, 30 Sep 2025 11:21:44 +0100 Subject: [PATCH 4/7] add batch tests --- .../requests/composition/multipleBatch.json | 89 +++++++++++++- tests/CTS/requests/composition/saveRules.json | 115 ++++++++++++++++-- 2 files changed, 187 insertions(+), 17 deletions(-) diff --git a/tests/CTS/requests/composition/multipleBatch.json b/tests/CTS/requests/composition/multipleBatch.json index 5fabb5d94a1..3bb0e7d3cdd 100644 --- a/tests/CTS/requests/composition/multipleBatch.json +++ b/tests/CTS/requests/composition/multipleBatch.json @@ -62,9 +62,7 @@ } }, { - "skipLanguages": [ - "kotlin" - ], + "skipLanguages": ["kotlin"], "parameters": { "requests": [ { @@ -147,9 +145,7 @@ } }, { - "skipLanguages": [ - "kotlin" - ], + "skipLanguages": ["kotlin"], "parameters": { "requests": [ { @@ -312,5 +308,86 @@ ] } } + }, + { + "skipLanguages": ["kotlin"], + "parameters": { + "requests": [ + { + "action": "upsert", + "body": { + "objectID": "my-compo", + "name": "my composition", + "behavior": { + "injection": { + "main": { + "source": { + "search": { + "index": "foo" + } + } + }, + "injectedItems": [ + { + "key": "injectedItem1", + "source": { + "search": { + "index": "foo" + } + }, + "position": 2, + "length": 1 + } + ], + "deduplication": { + "positioning": "highest" + } + } + } + } + } + ] + }, + "request": { + "path": "/1/compositions/*/batch", + "method": "POST", + "body": { + "requests": [ + { + "action": "upsert", + "body": { + "objectID": "my-compo", + "name": "my composition", + "behavior": { + "injection": { + "main": { + "source": { + "search": { + "index": "foo" + } + } + }, + "injectedItems": [ + { + "key": "injectedItem1", + "source": { + "search": { + "index": "foo" + } + }, + "position": 2, + "length": 1 + } + ], + "deduplication": { + "positioning": "highest" + } + } + } + } + } + ] + } + } } ] diff --git a/tests/CTS/requests/composition/saveRules.json b/tests/CTS/requests/composition/saveRules.json index 03069a1db1f..e564e8ae3d3 100644 --- a/tests/CTS/requests/composition/saveRules.json +++ b/tests/CTS/requests/composition/saveRules.json @@ -65,9 +65,7 @@ } }, { - "skipLanguages": [ - "kotlin" - ], + "skipLanguages": ["kotlin"], "parameters": { "compositionID": "rule-with-metadata", "rules": { @@ -200,10 +198,7 @@ "body": { "objectID": "rule-with-exernal-source", "description": "my description", - "tags": [ - "tag1", - "tag2" - ], + "tags": ["tag1", "tag2"], "enabled": true, "validity": [ { @@ -268,10 +263,7 @@ "body": { "objectID": "rule-with-exernal-source", "description": "my description", - "tags": [ - "tag1", - "tag2" - ], + "tags": ["tag1", "tag2"], "enabled": true, "validity": [ { @@ -326,5 +318,106 @@ ] } } + }, + { + "parameters": { + "compositionID": "my-compo", + "rules": { + "requests": [ + { + "action": "upsert", + "body": { + "objectID": "rule-with-deduplication", + "description": "my description", + "enabled": true, + "conditions": [ + { + "anchoring": "contains", + "pattern": "harry" + } + ], + "consequence": { + "behavior": { + "injection": { + "main": { + "source": { + "search": { + "index": "my-index" + } + } + }, + "injectedItems": [ + { + "key": "injectedItem", + "source": { + "search": { + "index": "my-index" + } + }, + "position": 0, + "length": 3 + } + ], + "deduplication": { + "positioning": "highestInjected" + } + } + } + } + } + } + ] + } + }, + "request": { + "path": "/1/compositions/my-compo/rules/batch", + "method": "POST", + "body": { + "requests": [ + { + "action": "upsert", + "body": { + "objectID": "rule-with-deduplication", + "description": "my description", + "enabled": true, + "conditions": [ + { + "anchoring": "contains", + "pattern": "harry" + } + ], + "consequence": { + "behavior": { + "injection": { + "main": { + "source": { + "search": { + "index": "my-index" + } + } + }, + "injectedItems": [ + { + "key": "injectedItem", + "source": { + "search": { + "index": "my-index" + } + }, + "position": 0, + "length": 3 + } + ], + "deduplication": { + "positioning": "highestInjected" + } + } + } + } + } + } + ] + } + } } ] From 91d2c0d11504dbdc9afd3fd90b469ff94fb38f3a Mon Sep 17 00:00:00 2001 From: Ben Kalmus Date: Tue, 30 Sep 2025 17:06:42 +0100 Subject: [PATCH 5/7] add required field for positioning --- .../common/schemas/components/CompositionBehavior.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/specs/composition/common/schemas/components/CompositionBehavior.yml b/specs/composition/common/schemas/components/CompositionBehavior.yml index 86046e5f5f1..10a8ca2f3df 100644 --- a/specs/composition/common/schemas/components/CompositionBehavior.yml +++ b/specs/composition/common/schemas/components/CompositionBehavior.yml @@ -49,6 +49,8 @@ compositionBehavior: properties: positioning: $ref: '#/dedupPositioning' + required: + - positioning required: - main required: From c84299af045e918ad03e0e9631b78519f9e54b74 Mon Sep 17 00:00:00 2001 From: Ben Kalmus Date: Wed, 1 Oct 2025 09:32:10 +0100 Subject: [PATCH 6/7] rename injected item key Co-authored-by: Clara Muller <5667350+ClaraMuller@users.noreply.github.com> --- tests/CTS/requests/composition/multipleBatch.json | 4 ++-- tests/CTS/requests/composition/putComposition.json | 4 ++-- tests/CTS/requests/composition/putCompositionRule.json | 4 ++-- tests/CTS/requests/composition/saveRules.json | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/tests/CTS/requests/composition/multipleBatch.json b/tests/CTS/requests/composition/multipleBatch.json index 3bb0e7d3cdd..a56d5c0b3dc 100644 --- a/tests/CTS/requests/composition/multipleBatch.json +++ b/tests/CTS/requests/composition/multipleBatch.json @@ -329,7 +329,7 @@ }, "injectedItems": [ { - "key": "injectedItem1", + "key": "my-injected-item-key", "source": { "search": { "index": "foo" @@ -369,7 +369,7 @@ }, "injectedItems": [ { - "key": "injectedItem1", + "key": "my-injected-item-key", "source": { "search": { "index": "foo" diff --git a/tests/CTS/requests/composition/putComposition.json b/tests/CTS/requests/composition/putComposition.json index 7cc586ed99f..56c3b345480 100644 --- a/tests/CTS/requests/composition/putComposition.json +++ b/tests/CTS/requests/composition/putComposition.json @@ -307,7 +307,7 @@ }, "injectedItems": [ { - "key": "injectedItem1", + "key": "my-injected-item-key", "source": { "search": { "index": "foo" @@ -344,7 +344,7 @@ }, "injectedItems": [ { - "key": "injectedItem1", + "key": "my-injected-item-key", "source": { "search": { "index": "foo" diff --git a/tests/CTS/requests/composition/putCompositionRule.json b/tests/CTS/requests/composition/putCompositionRule.json index 98c37a2a8f8..708229b2b09 100644 --- a/tests/CTS/requests/composition/putCompositionRule.json +++ b/tests/CTS/requests/composition/putCompositionRule.json @@ -332,7 +332,7 @@ }, "injectedItems": [ { - "key": "injectedItem", + "key": "my-injected-item-key", "source": { "search": { "index": "my-index" @@ -375,7 +375,7 @@ }, "injectedItems": [ { - "key": "injectedItem", + "key": "my-injected-item-key", "source": { "search": { "index": "my-index" diff --git a/tests/CTS/requests/composition/saveRules.json b/tests/CTS/requests/composition/saveRules.json index e564e8ae3d3..842e4fd79bd 100644 --- a/tests/CTS/requests/composition/saveRules.json +++ b/tests/CTS/requests/composition/saveRules.json @@ -348,7 +348,7 @@ }, "injectedItems": [ { - "key": "injectedItem", + "key": "injected-item-key", "source": { "search": { "index": "my-index" @@ -398,7 +398,7 @@ }, "injectedItems": [ { - "key": "injectedItem", + "key": "injected-item-key", "source": { "search": { "index": "my-index" From de01c212184ff42011902b156d5e96f7b30927af Mon Sep 17 00:00:00 2001 From: Ben Kalmus Date: Wed, 1 Oct 2025 10:52:10 +0100 Subject: [PATCH 7/7] modify injected item key --- tests/CTS/requests/composition/multipleBatch.json | 4 ++-- tests/CTS/requests/composition/putComposition.json | 4 ++-- tests/CTS/requests/composition/putCompositionRule.json | 4 ++-- tests/CTS/requests/composition/saveRules.json | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/tests/CTS/requests/composition/multipleBatch.json b/tests/CTS/requests/composition/multipleBatch.json index a56d5c0b3dc..1f620e46fab 100644 --- a/tests/CTS/requests/composition/multipleBatch.json +++ b/tests/CTS/requests/composition/multipleBatch.json @@ -329,7 +329,7 @@ }, "injectedItems": [ { - "key": "my-injected-item-key", + "key": "my-unique-injected-item-key", "source": { "search": { "index": "foo" @@ -369,7 +369,7 @@ }, "injectedItems": [ { - "key": "my-injected-item-key", + "key": "my-unique-injected-item-key", "source": { "search": { "index": "foo" diff --git a/tests/CTS/requests/composition/putComposition.json b/tests/CTS/requests/composition/putComposition.json index 56c3b345480..e95672ab842 100644 --- a/tests/CTS/requests/composition/putComposition.json +++ b/tests/CTS/requests/composition/putComposition.json @@ -307,7 +307,7 @@ }, "injectedItems": [ { - "key": "my-injected-item-key", + "key": "my-unique-injected-item-key", "source": { "search": { "index": "foo" @@ -344,7 +344,7 @@ }, "injectedItems": [ { - "key": "my-injected-item-key", + "key": "my-unique-injected-item-key", "source": { "search": { "index": "foo" diff --git a/tests/CTS/requests/composition/putCompositionRule.json b/tests/CTS/requests/composition/putCompositionRule.json index 708229b2b09..42c96f71900 100644 --- a/tests/CTS/requests/composition/putCompositionRule.json +++ b/tests/CTS/requests/composition/putCompositionRule.json @@ -332,7 +332,7 @@ }, "injectedItems": [ { - "key": "my-injected-item-key", + "key": "my-unique-injected-item-key", "source": { "search": { "index": "my-index" @@ -375,7 +375,7 @@ }, "injectedItems": [ { - "key": "my-injected-item-key", + "key": "my-unique-injected-item-key", "source": { "search": { "index": "my-index" diff --git a/tests/CTS/requests/composition/saveRules.json b/tests/CTS/requests/composition/saveRules.json index 842e4fd79bd..c525a5dcb04 100644 --- a/tests/CTS/requests/composition/saveRules.json +++ b/tests/CTS/requests/composition/saveRules.json @@ -348,7 +348,7 @@ }, "injectedItems": [ { - "key": "injected-item-key", + "key": "my-unique-injected-item-key", "source": { "search": { "index": "my-index" @@ -398,7 +398,7 @@ }, "injectedItems": [ { - "key": "injected-item-key", + "key": "my-unique-injected-item-key", "source": { "search": { "index": "my-index"