Use the document’s ID to delete one page or record from your Search App’s index.
Find the Document ID
Open Preview for your Search App and search for the page or record you want to delete. Find the matching result and copy its id value. For a crawled page, the ID is often the full page URL, as shown below.
Delete the Document
In the same Search App, go to App Settings > All APIs > Search & Indexing. Keep this screen open. You’ll copy the Update Endpoint and the Read & Write token from here when the command asks for them.
Use Token Authentication
- Open Terminal on macOS or a terminal with Bash on Linux. Copy and paste the entire block below, then press Enter.
- Paste the Update Endpoint and press Enter. Then paste the document ID and press Enter. Check that both are correct, then type
DELETEand press Enter. - Paste the Read & Write token and press Enter. Your terminal hides the token as you enter it.
bash -c "$(cat <<'SEARCHSTAX_DELETE'
if [[ ! -t 0 ]]; then
printf 'Paste this block into an interactive terminal.\n' >&2
exit 1
fi
IFS= read -r -p 'Update Endpoint: ' endpoint || exit 1
base=${endpoint%%\?*}
if [[ $base != https://*/update || $endpoint == *\#* ]]; then
printf 'Copy the HTTPS Update Endpoint from App Settings and try again.\n' >&2
exit 1
fi
IFS= read -r -p 'Document ID from Preview: ' document_id || exit 1
if [[ -z $document_id || $document_id == *[[:cntrl:]]* ]]; then
printf 'Copy the ID from one Preview result and try again.\n' >&2
exit 1
fi
printf '\nDocument ID: %s\nUpdate Endpoint: %s\n' "$document_id" "$base"
IFS= read -r -p 'Type DELETE to confirm: ' confirmation || exit 1
if [[ $confirmation != DELETE ]]; then
printf 'Canceled.\n'
exit 0
fi
IFS= read -r -s -p 'Read & Write token: ' token || exit 1
printf '\n'
if [[ -z $token || $token == *[[:space:][:cntrl:]]* ]]; then
printf 'Copy the Read & Write token and try again.\n' >&2
exit 1
fi
query=
if [[ $endpoint == *\?* ]]; then
IFS='&' read -r -a settings <<< "${endpoint#*\?}"
for setting in "${settings[@]}"; do
if [[ -n $setting && $setting != commit && $setting != commit=* ]]; then
query+="$setting&"
fi
done
fi
json_id=${document_id//\\/\\\\}
json_id=${json_id//\"/\\\"}
printf -v payload '{"delete":"%s"}' "$json_id"
printf 'Authorization: Token %s\n' "$token" |
curl --disable --fail --silent --show-error --globoff --proto '=https' \
--request POST --header @- --header 'Content-Type: application/json' \
--data-binary "$payload" --write-out '\nHTTP %{http_code}\n' \
--url "$base?${query}commit=true"
SEARCHSTAX_DELETE
)"
Check the Result
The request succeeded if the terminal shows HTTP 200 and "status": 0 in the response. Wait ten minutes, then open Preview in the same Search App and repeat your search. Confirm that the result with the ID you deleted no longer appears.
Use Basic Auth
If your Search App uses Basic Auth, use the app’s admin credentials with the request format below.
curl -X POST --location "<Site Search update URL>" /
-H "Content-Type: application/json" /
-d '{ "delete": { "query": "" } }' /
--basic --user <Site Search admin>:
Questions?
Do not hesitate to contact the SearchStax Support Desk.