main.sh
script.js
#!/usr/bin/env bash
SCRIPT=`cat script.js`
SCRIPT_STRING=`printf "$SCRIPT"|tr '\n' ' '`
CREDS="f51b4219a0ef:252c3f64-17a2-473f-b12d-6fe3b7066d48"
HOST="appbase-demo-ansible-abxiydt-arc.searchbase.io"
echo "https://$CREDS@$HOST/_script/validate"
curl -XPOST "https://$CREDS@$HOST/_script/validate" \
--header 'Content-Type: application/json' \
--data-raw '{
"script": "'"$SCRIPT_STRING"'",
"envs": {
"index": [
"best-buy-dataset"
]
},
"request": {
"body": {
"query": [
{
"id": "search",
"value": "mobiles",
"execute": false
},
{
"id": "results",
"react": {
"and": ["search"]
},
"includeFields": ["name"],
"size": 5
}
],
"settings": {
"enableQueryRules": false,
"userId": "john@appbase.io"
}
},
"headers": {
"X-Authorization": "c789f808ff7180552fd3ec7ac1432e03211d15521d5bb94606b693f62ed7f1aa"
}
}
}' | python -m json.tool | pygmentize -l json