Skip to content

Commit d9db762

Browse files
committed
add external source definition and runtime param
1 parent 3703081 commit d9db762

File tree

4 files changed

+81
-21
lines changed

4 files changed

+81
-21
lines changed

specs/composition-full/common/params/Composition.yml

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,37 @@ ruleContexts:
2626
default: []
2727
example: [mobile]
2828
x-categories:
29-
- Rules
29+
- Rules
30+
31+
injectedItems:
32+
type: array
33+
items:
34+
$ref: '#/externalInjectedItem'
35+
description: |
36+
A list of injected objectIDs into an external source.
37+
default: []
38+
example:
39+
[{'objectID': 'my-object-1', 'metadata': {'my-field': 'my-value'}}]
40+
x-categories:
41+
- Advanced
42+
43+
externalInjectedItem:
44+
type: object
45+
properties:
46+
objectID:
47+
type: string
48+
metadata:
49+
$ref: '#/injectedItemMetadata'
50+
description: |
51+
A list of injected objectIDs into an external source.
52+
required:
53+
- objectID
54+
example: {'objectID': 'my-object-1', 'metadata': {'my-field': 'my-value'}}
55+
56+
injectedItemMetadata:
57+
type: object
58+
additionalProperties: true
59+
description: |
60+
User defined key-values that will be added to injected item in the response.
61+
This is identical to Hits metadata which is defined in Composition or Composition Rule, with the benefit of being set at runtime.
62+
example: {'my-value': 'my-field'}

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

Lines changed: 7 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -54,25 +54,8 @@ injectedItem:
5454
type: string
5555
description: injected Item unique identifier.
5656
source:
57-
title: injectedItemSource
58-
type: object
59-
additionalProperties: false
60-
properties:
61-
search:
62-
title: injectedItemSourceSearch
63-
type: object
64-
additionalProperties: false
65-
properties:
66-
index:
67-
type: string
68-
description: Composition Main Index name.
69-
example: Products
70-
params:
71-
$ref: './Injection.yml#/injectedItemsQueryParameters'
72-
required:
73-
- index
74-
required:
75-
- search
57+
description: Search source to be used to inject items into result set.
58+
$ref: '#/injectionSource'
7659
position:
7760
type: integer
7861
minimum: 0
@@ -103,3 +86,8 @@ injectedItem:
10386
- source
10487
- position
10588
- length
89+
90+
injectionSource:
91+
oneOf:
92+
- $ref: './InjectionSource.yml#/search'
93+
- $ref: './InjectionSource.yml#/external'
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
search:
2+
title: injectedItemSearchSource
3+
description: Injected items will originate from a search request performed on the specified index.
4+
type: object
5+
additionalProperties: false
6+
allOf:
7+
- $ref: '#/baseSource'
8+
- type: object
9+
additionalProperties: false
10+
11+
external:
12+
title: injectedItemExternalSource
13+
description: Injected items will originate from externally provided objectIDs (that must exist in the index) given at runtime in the run request payload.
14+
type: object
15+
additionalProperties: false
16+
allOf:
17+
- $ref: '#/baseSource'
18+
properties:
19+
ordering:
20+
$ref: '#/externalOrdering'
21+
22+
baseSource:
23+
type: object
24+
additionalProperties: false
25+
properties:
26+
index:
27+
type: string
28+
description: Composition Index name.
29+
example: Products
30+
params:
31+
$ref: './Injection.yml#/injectedItemsQueryParameters'
32+
required:
33+
- index
34+
35+
externalOrdering:
36+
enum: ['default', 'user-defined']
37+
default: 'default'

specs/composition-full/common/schemas/requestBodies/RunParams.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,4 +54,6 @@ params:
5454
enableABTest:
5555
$ref: '../../params/Composition.yml#/enableABTest'
5656
enableReRanking:
57-
$ref: '../../params/Search.yml#/enableReRanking'
57+
$ref: '../../params/Search.yml#/enableReRanking'
58+
injectedItems:
59+
$ref: '../../params/Composition.yml#/injectedItems'

0 commit comments

Comments
 (0)