Skip to content

Commit 7de9435

Browse files
feat(specs): add compositions deduplication setting (#5418)
Co-authored-by: Clara Muller <5667350+ClaraMuller@users.noreply.github.com>
1 parent fc8c489 commit 7de9435

File tree

5 files changed

+378
-31
lines changed

5 files changed

+378
-31
lines changed

specs/composition/common/schemas/components/CompositionBehavior.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,16 @@ compositionBehavior:
4141
maxItems: 2
4242
items:
4343
$ref: '#/injectedItem'
44+
deduplication:
45+
title: deduplication
46+
type: object
47+
additionalProperties: false
48+
description: Deduplication configures the methods used to resolve duplicate items between main search results and injected group results.
49+
properties:
50+
positioning:
51+
$ref: '#/dedupPositioning'
52+
required:
53+
- positioning
4454
required:
4555
- main
4656
required:
@@ -91,3 +101,17 @@ injectedItemSource:
91101
oneOf:
92102
- $ref: './InjectionSource.yml#/SearchSource'
93103
- $ref: './InjectionSource.yml#/ExternalSource'
104+
105+
dedupPositioning:
106+
type: string
107+
enum:
108+
- highest
109+
- highestInjected
110+
description: |
111+
Deduplication positioning configures how a duplicate result should be resolved between an injected item and main search results.
112+
Current configuration supports:
113+
- 'highest': always select the item in the highest position, and remove duplicates that appear lower in the results.
114+
- 'highestInjected': duplicate result will be moved to its highest possible injected position, but not higher.
115+
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).
116+
example: highest
117+
default: highestInjected

tests/CTS/requests/composition/multipleBatch.json

Lines changed: 83 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,7 @@
6262
}
6363
},
6464
{
65-
"skipLanguages": [
66-
"kotlin"
67-
],
65+
"skipLanguages": ["kotlin"],
6866
"parameters": {
6967
"requests": [
7068
{
@@ -147,9 +145,7 @@
147145
}
148146
},
149147
{
150-
"skipLanguages": [
151-
"kotlin"
152-
],
148+
"skipLanguages": ["kotlin"],
153149
"parameters": {
154150
"requests": [
155151
{
@@ -312,5 +308,86 @@
312308
]
313309
}
314310
}
311+
},
312+
{
313+
"skipLanguages": ["kotlin"],
314+
"parameters": {
315+
"requests": [
316+
{
317+
"action": "upsert",
318+
"body": {
319+
"objectID": "my-compo",
320+
"name": "my composition",
321+
"behavior": {
322+
"injection": {
323+
"main": {
324+
"source": {
325+
"search": {
326+
"index": "foo"
327+
}
328+
}
329+
},
330+
"injectedItems": [
331+
{
332+
"key": "my-unique-injected-item-key",
333+
"source": {
334+
"search": {
335+
"index": "foo"
336+
}
337+
},
338+
"position": 2,
339+
"length": 1
340+
}
341+
],
342+
"deduplication": {
343+
"positioning": "highest"
344+
}
345+
}
346+
}
347+
}
348+
}
349+
]
350+
},
351+
"request": {
352+
"path": "/1/compositions/*/batch",
353+
"method": "POST",
354+
"body": {
355+
"requests": [
356+
{
357+
"action": "upsert",
358+
"body": {
359+
"objectID": "my-compo",
360+
"name": "my composition",
361+
"behavior": {
362+
"injection": {
363+
"main": {
364+
"source": {
365+
"search": {
366+
"index": "foo"
367+
}
368+
}
369+
},
370+
"injectedItems": [
371+
{
372+
"key": "my-unique-injected-item-key",
373+
"source": {
374+
"search": {
375+
"index": "foo"
376+
}
377+
},
378+
"position": 2,
379+
"length": 1
380+
}
381+
],
382+
"deduplication": {
383+
"positioning": "highest"
384+
}
385+
}
386+
}
387+
}
388+
}
389+
]
390+
}
391+
}
315392
}
316393
]

tests/CTS/requests/composition/putComposition.json

Lines changed: 76 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -134,9 +134,7 @@
134134
}
135135
},
136136
{
137-
"skipLanguages": [
138-
"kotlin"
139-
],
137+
"skipLanguages": ["kotlin"],
140138
"parameters": {
141139
"compositionID": "my-metadata-compo",
142140
"composition": {
@@ -288,5 +286,80 @@
288286
}
289287
}
290288
}
289+
},
290+
{
291+
"parameters": {
292+
"compositionID": "my-compo",
293+
"composition": {
294+
"objectID": "my-compo",
295+
"name": "my composition",
296+
"behavior": {
297+
"injection": {
298+
"main": {
299+
"source": {
300+
"search": {
301+
"index": "foo",
302+
"params": {
303+
"filters": "brand:adidas"
304+
}
305+
}
306+
}
307+
},
308+
"injectedItems": [
309+
{
310+
"key": "my-unique-injected-item-key",
311+
"source": {
312+
"search": {
313+
"index": "foo"
314+
}
315+
},
316+
"position": 2,
317+
"length": 1
318+
}
319+
],
320+
"deduplication": {
321+
"positioning": "highest"
322+
}
323+
}
324+
}
325+
}
326+
},
327+
"request": {
328+
"path": "/1/compositions/my-compo",
329+
"method": "PUT",
330+
"body": {
331+
"objectID": "my-compo",
332+
"name": "my composition",
333+
"behavior": {
334+
"injection": {
335+
"main": {
336+
"source": {
337+
"search": {
338+
"index": "foo",
339+
"params": {
340+
"filters": "brand:adidas"
341+
}
342+
}
343+
}
344+
},
345+
"injectedItems": [
346+
{
347+
"key": "my-unique-injected-item-key",
348+
"source": {
349+
"search": {
350+
"index": "foo"
351+
}
352+
},
353+
"position": 2,
354+
"length": 1
355+
}
356+
],
357+
"deduplication": {
358+
"positioning": "highest"
359+
}
360+
}
361+
}
362+
}
363+
}
291364
}
292365
]

tests/CTS/requests/composition/putCompositionRule.json

Lines changed: 91 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,7 @@
7878
}
7979
},
8080
{
81-
"skipLanguages": [
82-
"kotlin"
83-
],
81+
"skipLanguages": ["kotlin"],
8482
"parameters": {
8583
"compositionID": "compositionID",
8684
"objectID": "rule-with-metadata",
@@ -197,10 +195,7 @@
197195
"compositionRule": {
198196
"objectID": "rule-with-exernal-source",
199197
"description": "my description",
200-
"tags": [
201-
"tag1",
202-
"tag2"
203-
],
198+
"tags": ["tag1", "tag2"],
204199
"enabled": true,
205200
"validity": [
206201
{
@@ -258,10 +253,7 @@
258253
"body": {
259254
"objectID": "rule-with-exernal-source",
260255
"description": "my description",
261-
"tags": [
262-
"tag1",
263-
"tag2"
264-
],
256+
"tags": ["tag1", "tag2"],
265257
"enabled": true,
266258
"validity": [
267259
{
@@ -313,5 +305,93 @@
313305
}
314306
}
315307
}
308+
},
309+
{
310+
"parameters": {
311+
"compositionID": "compositionID",
312+
"objectID": "rule-with-deduplication",
313+
"compositionRule": {
314+
"objectID": "rule-with-deduplication",
315+
"description": "my description",
316+
"enabled": true,
317+
"conditions": [
318+
{
319+
"anchoring": "contains",
320+
"pattern": "harry"
321+
}
322+
],
323+
"consequence": {
324+
"behavior": {
325+
"injection": {
326+
"main": {
327+
"source": {
328+
"search": {
329+
"index": "my-index"
330+
}
331+
}
332+
},
333+
"injectedItems": [
334+
{
335+
"key": "my-unique-injected-item-key",
336+
"source": {
337+
"search": {
338+
"index": "my-index"
339+
}
340+
},
341+
"position": 0,
342+
"length": 3
343+
}
344+
],
345+
"deduplication": {
346+
"positioning": "highestInjected"
347+
}
348+
}
349+
}
350+
}
351+
}
352+
},
353+
"request": {
354+
"path": "/1/compositions/compositionID/rules/rule-with-deduplication",
355+
"method": "PUT",
356+
"body": {
357+
"objectID": "rule-with-deduplication",
358+
"description": "my description",
359+
"enabled": true,
360+
"conditions": [
361+
{
362+
"anchoring": "contains",
363+
"pattern": "harry"
364+
}
365+
],
366+
"consequence": {
367+
"behavior": {
368+
"injection": {
369+
"main": {
370+
"source": {
371+
"search": {
372+
"index": "my-index"
373+
}
374+
}
375+
},
376+
"injectedItems": [
377+
{
378+
"key": "my-unique-injected-item-key",
379+
"source": {
380+
"search": {
381+
"index": "my-index"
382+
}
383+
},
384+
"position": 0,
385+
"length": 3
386+
}
387+
],
388+
"deduplication": {
389+
"positioning": "highestInjected"
390+
}
391+
}
392+
}
393+
}
394+
}
395+
}
316396
}
317397
]

0 commit comments

Comments
 (0)