Mit dem /search
-Endpunkt in der Reactor-API können Sie strukturierte Abfragen zu gespeicherten Ressourcen durchführen. Dieses Dokument enthält Beispiele für verschiedene Suchanfragen für diverse gängige Anwendungsfälle.
Bevor Sie dieses Handbuch lesen, lesen Sie das Handbuch zum Suchen von Endpunkten, um Informationen zur akzeptierten Abfragesyntax und anderen Nutzungsrichtlinien zu erhalten.
Die folgenden Beispiele zeigen einige grundlegende Konzepte für die Verwendung der Suchfunktion der API.
Eine Suche kann über mehrere Felder hinweg mithilfe von Platzhaltern im Feldnamen durchgeführt werden. Um beispielsweise mehrere Attributfelder zu durchsuchen, verwenden Sie attributes.*
als Feldnamen.
{
"data": {
"query": {
"attributes.*": {
"value": "evar7"
}
}
}
}
Normalerweise müssen die Suchwerte mit dem Typ der gesuchten Daten übereinstimmen. Beispielsweise würde ein Abfragewert evar7
für ein ganzzahliges Feld fehlschlagen. Bei der Suche über mehrere Felder wird die Anforderung an den Abfragetyp gelockert, um Fehler zu vermeiden, was jedoch zu unerwünschten Ergebnissen führen kann.
Sie können eine Suche auf einen bestimmten Ressourcentyp beschränken, indem Sie in der Anfrage resource_types
angeben. So suchen Sie beispielsweise nach data_elements
und rule_components
:
{
"data": {
"from": 0,
"size": 25,
"query": {
"attributes.display_name": {
"value": "Performance"
}
},
"resource_types": [
"data_elements",
"rule_components"
]
}
}
Die Eigenschaft sort
kann zum Sortieren von Antworten verwendet werden. Beispiel: Sortieren nach created_at
mit dem neuesten zuerst:
{
"data": {
"from": 0,
"size": 25,
"query": {
"attributes.display_name": {
"value": "Performance"
}
},
"sort": [
{
"attributes.created_at": "desc"
}
],
"resource_types": [
"data_elements",
"rule_components"
]
}
}
Im folgenden Beispiel werden zusätzliche gängige Suchmuster veranschaulicht.
curl -X POST \
https://reactor.adobe.io/search \
-H 'Authorization: Bearer {ACCESS_TOKEN}' \
-H 'x-api-key: {API_KEY}' \
-H 'x-gw-ims-org-id: {ORG_ID}' \
-H "Content-Type: application/vnd.api+json" \
-H 'Accept: application/vnd.api+json;revision=1' \
-d '{
"data": {
"query": {
"attributes.name": {
"value": "Adobe"
}
}
}
}'
curl -X POST \
https://reactor.adobe.io/search \
-H 'Authorization: Bearer {ACCESS_TOKEN}' \
-H 'x-api-key: {API_KEY}' \
-H 'x-gw-ims-org-id: {ORG_ID}' \
-H "Content-Type: application/vnd.api+json" \
-H 'Accept: application/vnd.api+json;revision=1' \
-d '{
"data": {
"query": {
"attributes.*": {
"value": "evar7"
}
}
}
}'
curl -X POST \
https://reactor.adobe.io/search \
-H 'Authorization: Bearer {ACCESS_TOKEN}' \
-H 'x-api-key: {API_KEY}' \
-H 'x-gw-ims-org-id: {ORG_ID}' \
-H "Content-Type: application/vnd.api+json" \
-H 'Accept: application/vnd.api+json;revision=1' \
-d '{
"data": {
"query": {
"attributes.delegate_descriptor_id": {
"value": "custom-code"
}
},
"resource_types": ["data_elements"]
}
}'
curl -X POST \
https://reactor.adobe.io/search \
-H 'Authorization: Bearer {ACCESS_TOKEN}' \
-H 'x-api-key: {API_KEY}' \
-H 'x-gw-ims-org-id: {ORG_ID}' \
-H "Content-Type: application/vnd.api+json" \
-H 'Accept: application/vnd.api+json;revision=1' \
-d '{
"data": {
"query": {
"attributes.settings": {
"value": "myDataElement8"
}
},
"resource_types": ["rule_components"]
}
}'
curl -X POST \
https://reactor.adobe.io/search \
-H 'Authorization: Bearer {ACCESS_TOKEN}' \
-H 'x-api-key: {API_KEY}' \
-H 'x-gw-ims-org-id: {ORG_ID}' \
-H "Content-Type: application/vnd.api+json" \
-H 'Accept: application/vnd.api+json;revision=1' \
-d '{
"data": {
"query": {
"relationships.property.data.id": {
"value": "PR3cab070a9eb3423894e4a3038ef0e7b7"
}
},
"resource_types": ["rules"]
}
}'
curl -X POST \
https://reactor.adobe.io/search \
-H 'Authorization: Bearer {ACCESS_TOKEN}' \
-H 'x-api-key: {API_KEY}' \
-H 'x-gw-ims-org-id: {ORG_ID}' \
-H "Content-Type: application/vnd.api+json" \
-H 'Accept: application/vnd.api+json;revision=1' \
-d '{
"data": {
"query": {
"id": {
"value": "PR3cab070a9eb3423894e4a3038ef0e7b7"
}
}
}
}'
curl -X POST \
https://reactor.adobe.io/search \
-H 'Authorization: Bearer {ACCESS_TOKEN}' \
-H 'x-api-key: {API_KEY}' \
-H 'x-gw-ims-org-id: {ORG_ID}' \
-H "Content-Type: application/vnd.api+json" \
-H 'Accept: application/vnd.api+json;revision=1' \
-d '{
"data": {
"query": {
"attributes.display_name": {
"value": "My Rule Holiday Sale",
"value_operator: "OR"
}
}
}
}'