Skip to main content
Version: 2.0

Scripting Endpoints

Scripts are a GraphGrid Search functionality that expose the scripting capabilities that Elasticsearch offers.

Register Script

Register a script to be used by Elasticsearch.

Base URL: /1.0/search/{{clusterName}}/scripts/{{scriptId}}
Method: POST

ParameterDescription
clusterName stringThe GraphGrid Cluster with an Index Policy.
scriptId stringThe name of the script.

Request

curl --location --request GET "${API_BASE}/1.0/search/default/scripts/testTemplate" \
--header 'Content-Type: application/json' \
--header "Authorization: Bearer ${BEARER_TOKEN}" \
--data-raw '{
"from": 2,
"size": 20,
"propertyPreference": {
"{{my_property_1}}": {
"include": false
},
"dataSource": {
"include": false
}
},
"query": {
"queryType": "match",
"value": "{{my_value}}",
"property": "{{my_property_2}}",
"operator": "{{my_operator}}"
},
"params": {
"my_value": "keanu reeves",
"my_property_1": "hiddenProperty",
"my_property_2": "name",
"my_operator": "AND"
}
}'

Response

{
"_id": "default_testTemplate",
"found": true,
"source": "{\"_source\":{\"includes\":[],\"excludes\":[\"{{my_property_1}}\",\"dataSource\"]},\"from\":\"2\",\"size\":\"20\",\"query\":{\"match\":{\"{{my_property_2}}\":{\"query\":\"{{my_value}}\",\"operator\":\"{{my_operator}}\",\"prefix_length\":0,\"max_expansions\":50,\"fuzzy_transpositions\":true,\"lenient\":false,\"zero_terms_query\":\"NONE\",\"auto_generate_synonyms_phrase_query\":true,\"boost\":1.0}}}}"
}

Invoke Script

Execute a search parameter using the script.

Base URL: /1.0/search/{{clusterName}}/{{policyName}}/**
Method: GET

ParameterDescription
clusterName stringThe GraphGrid Cluster with an Index Policy.
policyName stringThe name used to load the index policy on S3.

Request

curl --location --request GET "${API_BASE}/1.0/search/default/gg-dev-index-policy/?query=%7B%0A%20%20%20%22templatedId%22:%20%22default_testTemplate%22,%0A%20%20%20%22query%22:%20%7B%0A%20%20%20%20%20%20%20%22queryType%22:%20%22term%22,%0A%20%20%20%20%20%20%20%22value%22:%20%22thatTerm%22,%0A%20%20%20%20%20%20%20%22property%22:%20%22thatProperty%22%0A%20%20%20%7D%0A%7D" \
--header 'Content-Type: application/json' \
--header "Authorization: Bearer ${BEARER_TOKEN}" \
--data-raw ''

Response

{
"report": {
"summary": {
"totalCount": 0
}
},
"data": {},
"suggest": {},
"collapse": {},
"searchParams": {}
}

Get Script

Retrieves and returns a script.

Base URL: /1.0/search/{{clusterName}}/scripts/{{scriptId}}
Method: GET

ParameterDescription
clusterName stringThe GraphGrid Cluster with an Index Policy.
scriptId stringThe name of the script.

Request

curl --location --request GET "${API_BASE}/1.0/search/default/scripts/testTemplate" \
--header 'Content-Type: application/json' \
--header "Authorization: Bearer ${BEARER_TOKEN}"

Delete Script

Deletes a script.

Base URL: /1.0/search/{{clusterName}}/scripts/{{scriptId}}
Method: DELETE

ParameterDescription
clusterName stringThe GraphGrid Cluster with an Index Policy.
scriptId stringThe name of the script.

Request

curl --location --request DELETE "${API_BASE}/1.0/search/default/scripts/testTemplate" \
--header 'Content-Type: application/json' \
--header "Authorization: Bearer ${BEARER_TOKEN}"

Response

{
"acknowledged": true
}