diff --git a/specs/composition-full/common/schemas/components/CompositionRule.yml b/specs/composition-full/common/schemas/components/CompositionRule.yml index 2bf9f3939b..f696e68759 100644 --- a/specs/composition-full/common/schemas/components/CompositionRule.yml +++ b/specs/composition-full/common/schemas/components/CompositionRule.yml @@ -34,6 +34,12 @@ compositionRule: description: Time periods when the rule is active. items: $ref: '../../../../common/schemas/Rule.yml#/timeRange' + tags: + type: array + description: A list of tags. + items: + type: string + example: ['conditional'] required: - objectID - conditions @@ -76,4 +82,4 @@ anchoring: - `contains`. The pattern must match anywhere in the query. Empty queries are only allowed as patterns with `anchoring: is`. - enum: [is, startsWith, endsWith, contains] \ No newline at end of file + enum: [is, startsWith, endsWith, contains] diff --git a/tests/CTS/requests/composition-full/multipleBatch.json b/tests/CTS/requests/composition-full/multipleBatch.json index 52bcd79e03..413b022be9 100644 --- a/tests/CTS/requests/composition-full/multipleBatch.json +++ b/tests/CTS/requests/composition-full/multipleBatch.json @@ -62,5 +62,249 @@ ] } } + }, + + { + "parameters": { + "requests": [ + { + "action": "upsert", + "body": { + "objectID": "my-external-injection-compo", + "name": "my first composition", + "behavior": { + "injection": { + "main": { + "source": { + "search": { + "index": "foo" + } + } + }, + "injectedItems": [ + { + "key": "injectedItem1", + "source": { + "external": { + "index": "foo", + "ordering": "userDefined", + "params": { + "filters": "brand:adidas" + } + } + }, + "position": 2, + "length": 1 + } + ] + } + } + } + } + ] + }, + "request": { + "path": "/1/compositions/*/batch", + "method": "POST", + "body": { + "requests": [ + { + "action": "upsert", + "body": { + "objectID": "my-external-injection-compo", + "name": "my first composition", + "behavior": { + "injection": { + "main": { + "source": { + "search": { + "index": "foo" + } + } + }, + "injectedItems": [ + { + "key": "injectedItem1", + "source": { + "external": { + "index": "foo", + "ordering": "userDefined", + "params": { + "filters": "brand:adidas" + } + } + }, + "position": 2, + "length": 1 + } + ] + } + } + } + } + ] + } + } + }, + + { + "parameters": { + "requests": [ + { + "action": "upsert", + "body": { + "objectID": "my-metadata-compo", + "name": "my composition", + "behavior": { + "injection": { + "main": { + "source": { + "search": { + "index": "foo", + "params": { "filters": "brand:adidas" } + } + } + }, + "injectedItems": [ + { + "key": "injectedItem1", + "source": { + "search": { + "index": "foo", + "params": { + "filters": "brand:adidas" + } + } + }, + "position": 2, + "length": 1, + "metadata": { + "hits": { + "addItemKey": true, + "extra": { + "my-string": "string", + "my-bool": true, + "my-number": 42, + "my-object": { "sub-key": "sub-value" }, + "my-array": [1, 2, 3], + "my-empty-object": {} + } + } + } + }, + { + "key": "externalItem", + "source": { + "search": { + "index": "foo", + "params": { + "filters": "brand:puma" + } + } + }, + "position": 5, + "length": 5, + "metadata": { + "hits": { + "addItemKey": true, + "extra": { + "my-string": "string", + "my-bool": true, + "my-number": 42, + "my-object": { "sub-key": "sub-value" }, + "my-array": [1, 2, 3], + "my-empty-object": {} + } + } + } + } + ] + } + } + } + } + ] + }, + "request": { + "path": "/1/compositions/*/batch", + "method": "POST", + "body": { + "requests": [ + { + "action": "upsert", + "body": { + "objectID": "my-metadata-compo", + "name": "my composition", + "behavior": { + "injection": { + "main": { + "source": { + "search": { + "index": "foo", + "params": { "filters": "brand:adidas" } + } + } + }, + "injectedItems": [ + { + "key": "injectedItem1", + "source": { + "search": { + "index": "foo", + "params": { + "filters": "brand:adidas" + } + } + }, + "position": 2, + "length": 1, + "metadata": { + "hits": { + "addItemKey": true, + "extra": { + "my-string": "string", + "my-bool": true, + "my-number": 42, + "my-object": { "sub-key": "sub-value" }, + "my-array": [1, 2, 3], + "my-empty-object": {} + } + } + } + }, + { + "key": "externalItem", + "source": { + "search": { + "index": "foo", + "params": { + "filters": "brand:puma" + } + } + }, + "position": 5, + "length": 5, + "metadata": { + "hits": { + "addItemKey": true, + "extra": { + "my-string": "string", + "my-bool": true, + "my-number": 42, + "my-object": { "sub-key": "sub-value" }, + "my-array": [1, 2, 3], + "my-empty-object": {} + } + } + } + } + ] + } + } + } + } + ] + } + } } ] diff --git a/tests/CTS/requests/composition-full/putComposition.json b/tests/CTS/requests/composition-full/putComposition.json index af1874b211..f0434ecc91 100644 --- a/tests/CTS/requests/composition-full/putComposition.json +++ b/tests/CTS/requests/composition-full/putComposition.json @@ -62,6 +62,7 @@ } } }, + { "parameters": { "compositionID": "my-external-injection-compo", @@ -132,5 +133,155 @@ } } } + }, + + { + "parameters": { + "compositionID": "my-metadata-compo", + "composition": { + "objectID": "my-metadata-compo", + "name": "my composition", + "behavior": { + "injection": { + "main": { + "source": { + "search": { + "index": "foo", + "params": { "filters": "brand:adidas" } + } + } + }, + "injectedItems": [ + { + "key": "injectedItem1", + "source": { + "search": { + "index": "foo", + "params": { + "filters": "brand:adidas" + } + } + }, + "position": 2, + "length": 1, + "metadata": { + "hits": { + "addItemKey": true, + "extra": { + "my-string": "string", + "my-bool": true, + "my-number": 42, + "my-object": { "sub-key": "sub-value" }, + "my-array": [1, 2, 3], + "my-empty-object": {} + } + } + } + }, + { + "key": "externalItem", + "source": { + "search": { + "index": "foo", + "params": { + "filters": "brand:puma" + } + } + }, + "position": 5, + "length": 5, + "metadata": { + "hits": { + "addItemKey": true, + "extra": { + "my-string": "string", + "my-bool": true, + "my-number": 42, + "my-object": { "sub-key": "sub-value" }, + "my-array": [1, 2, 3], + "my-empty-object": {} + } + } + } + } + ] + } + } + } + }, + "request": { + "path": "/1/compositions/my-metadata-compo", + "method": "PUT", + "body": { + "objectID": "my-metadata-compo", + "name": "my composition", + "behavior": { + "injection": { + "main": { + "source": { + "search": { + "index": "foo", + "params": { "filters": "brand:adidas" } + } + } + }, + "injectedItems": [ + { + "key": "injectedItem1", + "source": { + "search": { + "index": "foo", + "params": { + "filters": "brand:adidas" + } + } + }, + "position": 2, + "length": 1, + "metadata": { + "hits": { + "addItemKey": true, + "extra": { + "my-string": "string", + "my-bool": true, + "my-number": 42, + "my-object": { "sub-key": "sub-value" }, + "my-array": [1, 2, 3], + "my-empty-object": {} + } + } + } + }, + { + "key": "externalItem", + "source": { + "search": { + "index": "foo", + "params": { + "filters": "brand:puma" + } + } + }, + "position": 5, + "length": 5, + "metadata": { + "hits": { + "addItemKey": true, + "extra": { + "my-string": "string", + "my-bool": true, + "my-number": 42, + "my-object": { "sub-key": "sub-value" }, + "my-array": [1, 2, 3], + "my-empty-object": {} + } + } + } + } + ] + } + } + } + } } ] diff --git a/tests/CTS/requests/composition-full/putCompositionRule.json b/tests/CTS/requests/composition-full/putCompositionRule.json index ddb6ffaed4..30b692e937 100644 --- a/tests/CTS/requests/composition-full/putCompositionRule.json +++ b/tests/CTS/requests/composition-full/putCompositionRule.json @@ -1,10 +1,10 @@ [ { "parameters": { - "compositionID": "1234", - "objectID": "5678", + "compositionID": "compositionID", + "objectID": "ruleID", "compositionRule": { - "objectID": "5678", + "objectID": "ruleID", "conditions": [ { "anchoring": "is", @@ -39,10 +39,10 @@ } }, "request": { - "path": "/1/compositions/1234/rules/5678", + "path": "/1/compositions/compositionID/rules/ruleID", "method": "PUT", "body": { - "objectID": "5678", + "objectID": "ruleID", "conditions": [ { "anchoring": "is", @@ -76,5 +76,205 @@ } } } + }, + + { + "parameters": { + "compositionID": "compositionID", + "objectID": "rule-with-metadata", + "compositionRule": { + "objectID": "rule-with-metadata", + "conditions": [ + { + "anchoring": "is", + "pattern": "test" + } + ], + "consequence": { + "behavior": { + "injection": { + "main": { + "source": { + "search": { + "index": "foo" + } + } + }, + "injectedItems": [ + { + "key": "injectedItem1", + "source": { + "search": { + "index": "foo", + "params": { + "filters": "brand:adidas" + } + } + }, + "position": 2, + "length": 1, + "metadata": { + "hits": { + "addItemKey": true, + "extra": { + "my-string": "string", + "my-bool": true, + "my-number": 42, + "my-object": { "sub-key": "sub-value" }, + "my-array": [1, 2, 3], + "my-empty-object": {} + } + } + } + } + ] + } + } + } + } + }, + "request": { + "path": "/1/compositions/compositionID/rules/rule-with-metadata", + "method": "PUT", + "body": { + "objectID": "rule-with-metadata", + "conditions": [ + { + "anchoring": "is", + "pattern": "test" + } + ], + "consequence": { + "behavior": { + "injection": { + "main": { + "source": { + "search": { + "index": "foo" + } + } + }, + "injectedItems": [ + { + "key": "injectedItem1", + "source": { + "search": { + "index": "foo", + "params": { + "filters": "brand:adidas" + } + } + }, + "position": 2, + "length": 1, + "metadata": { + "hits": { + "addItemKey": true, + "extra": { + "my-string": "string", + "my-bool": true, + "my-number": 42, + "my-object": { "sub-key": "sub-value" }, + "my-array": [1, 2, 3], + "my-empty-object": {} + } + } + } + } + ] + } + } + } + } + } + }, + + { + "parameters": { + "compositionID": "compositionID", + "objectID": "rule-with-exernal-source", + "compositionRule": { + "objectID": "rule-with-exernal-source", + "description": "my description", + "tags": ["tag1", "tag2"], + "enabled": true, + "validity": [{ "from": 1704063600, "until": 1704083600 }], + "conditions": [ + { "anchoring": "contains", "pattern": "harry" }, + { "anchoring": "contains", "pattern": "potter" } + ], + "consequence": { + "behavior": { + "injection": { + "main": { + "source": { + "search": { + "index": "my-index", + "params": { "filters": "brand:adidas" } + } + } + }, + "injectedItems": [ + { + "key": "injectedItem", + "source": { + "external": { + "index": "my-index", + "params": { "filters": "brand:adidas" }, + "ordering": "userDefined" + } + }, + "position": 0, + "length": 3 + } + ] + } + } + } + } + }, + "request": { + "path": "/1/compositions/compositionID/rules/rule-with-exernal-source", + "method": "PUT", + "body": { + "objectID": "rule-with-exernal-source", + "description": "my description", + "tags": ["tag1", "tag2"], + "enabled": true, + "validity": [{ "from": 1704063600, "until": 1704083600 }], + "conditions": [ + { "anchoring": "contains", "pattern": "harry" }, + { "anchoring": "contains", "pattern": "potter" } + ], + "consequence": { + "behavior": { + "injection": { + "main": { + "source": { + "search": { + "index": "my-index", + "params": { "filters": "brand:adidas" } + } + } + }, + "injectedItems": [ + { + "key": "injectedItem", + "source": { + "external": { + "index": "my-index", + "params": { "filters": "brand:adidas" }, + "ordering": "userDefined" + } + }, + "position": 0, + "length": 3 + } + ] + } + } + } + } + } } ] diff --git a/tests/CTS/requests/composition-full/saveRules.json b/tests/CTS/requests/composition-full/saveRules.json index 1cafbabd0e..beee5baecc 100644 --- a/tests/CTS/requests/composition-full/saveRules.json +++ b/tests/CTS/requests/composition-full/saveRules.json @@ -63,5 +63,231 @@ ] } } + }, + + { + "parameters": { + "compositionID": "rule-with-metadata", + "rules": { + "requests": [ + { + "action": "upsert", + "body": { + "objectID": "rule-with-metadata", + "conditions": [ + { + "anchoring": "is", + "pattern": "test" + } + ], + "consequence": { + "behavior": { + "injection": { + "main": { + "source": { + "search": { + "index": "foo" + } + } + }, + "injectedItems": [ + { + "key": "injectedItem1", + "source": { + "search": { + "index": "foo", + "params": { + "filters": "brand:adidas" + } + } + }, + "position": 2, + "length": 1, + "metadata": { + "hits": { + "addItemKey": true, + "extra": { + "my-string": "string", + "my-bool": true, + "my-number": 42, + "my-object": { "sub-key": "sub-value" }, + "my-array": [1, 2, 3], + "my-empty-object": {} + } + } + } + } + ] + } + } + } + } + } + ] + } + }, + "request": { + "path": "/1/compositions/rule-with-metadata/rules/batch", + "method": "POST", + "body": { + "requests": [ + { + "action": "upsert", + "body": { + "objectID": "rule-with-metadata", + "conditions": [ + { + "anchoring": "is", + "pattern": "test" + } + ], + "consequence": { + "behavior": { + "injection": { + "main": { + "source": { + "search": { + "index": "foo" + } + } + }, + "injectedItems": [ + { + "key": "injectedItem1", + "source": { + "search": { + "index": "foo", + "params": { + "filters": "brand:adidas" + } + } + }, + "position": 2, + "length": 1, + "metadata": { + "hits": { + "addItemKey": true, + "extra": { + "my-string": "string", + "my-bool": true, + "my-number": 42, + "my-object": { "sub-key": "sub-value" }, + "my-array": [1, 2, 3], + "my-empty-object": {} + } + } + } + } + ] + } + } + } + } + } + ] + } + } + }, + + { + "parameters": { + "compositionID": "rule-with-exernal-source", + "rules": { + "requests": [ + { + "action": "upsert", + "body": { + "objectID": "rule-with-exernal-source", + "description": "my description", + "tags": ["tag1", "tag2"], + "enabled": true, + "validity": [{ "from": 1704063600, "until": 1704083600 }], + "conditions": [ + { "anchoring": "contains", "pattern": "harry" }, + { "anchoring": "contains", "pattern": "potter" } + ], + "consequence": { + "behavior": { + "injection": { + "main": { + "source": { + "search": { + "index": "my-index", + "params": { "filters": "brand:adidas" } + } + } + }, + "injectedItems": [ + { + "key": "injectedItem", + "source": { + "external": { + "index": "my-index", + "params": { "filters": "brand:adidas" }, + "ordering": "userDefined" + } + }, + "position": 0, + "length": 3 + } + ] + } + } + } + } + } + ] + } + }, + "request": { + "path": "/1/compositions/rule-with-exernal-source/rules/batch", + "method": "POST", + "body": { + "requests": [ + { + "action": "upsert", + "body": { + "objectID": "rule-with-exernal-source", + "description": "my description", + "tags": ["tag1", "tag2"], + "enabled": true, + "validity": [{ "from": 1704063600, "until": 1704083600 }], + "conditions": [ + { "anchoring": "contains", "pattern": "harry" }, + { "anchoring": "contains", "pattern": "potter" } + ], + "consequence": { + "behavior": { + "injection": { + "main": { + "source": { + "search": { + "index": "my-index", + "params": { "filters": "brand:adidas" } + } + } + }, + "injectedItems": [ + { + "key": "injectedItem", + "source": { + "external": { + "index": "my-index", + "params": { "filters": "brand:adidas" }, + "ordering": "userDefined" + } + }, + "position": 0, + "length": 3 + } + ] + } + } + } + } + } + ] + } + } } ] diff --git a/tests/CTS/requests/composition-full/search.json b/tests/CTS/requests/composition-full/search.json index 367fd9378a..6ca8776a0c 100644 --- a/tests/CTS/requests/composition-full/search.json +++ b/tests/CTS/requests/composition-full/search.json @@ -29,7 +29,12 @@ { "objectID": "my-object-2", "metadata": { - "my-key": "my-value" + "my-string": "string", + "my-bool": true, + "my-number": 42, + "my-object": { "sub-key": "sub-value" }, + "my-array": [1, 2, 3], + "my-empty-object": {} } } ] @@ -53,7 +58,12 @@ { "objectID": "my-object-2", "metadata": { - "my-key": "my-value" + "my-string": "string", + "my-bool": true, + "my-number": 42, + "my-object": { "sub-key": "sub-value" }, + "my-array": [1, 2, 3], + "my-empty-object": {} } } ]