Managed Search API – ZooKeeper


Overview

SearchStax provides an API supporting the creation, deletion and management of SearchStax Managed Search service deployments.

Platinum and Platinum Plus Clients Only!

The SearchStax API suite is available to our Platinum and Platinum Plus clients only, as noted on our Pricing page.

This page describes how to manage ZooKeeper configurations using API methods.

The API can be accessed through any tool that assembles HTTP requests and dispatch them to a server. Among these would be the Python coreapi package, the Postman tool, and cURL. For Windows, use a version of PowerShell that supports multipart-form data, such as PowerShell Core 6.1+ or Powershell 7+.

Account Owner, Admin, or Technical Contact

To run the SearchStax Provisioning API, you must be the account Owner, an account Admin, or a Technical Contact. See SearchStax User Roles.

Symbols enclosed in carets (< and >) such as <username> are metavariables. Substitute your local values when you encounter them in the examples.

Contents:

Related Page:

Zookeeper

The Provisioning API includes methods for accessing Zookeeper configuration sets.

account > deployment > zookeeper-config > list

This method returns a list of named configurations from a Zookeeper ensemble.

GET /api/rest/v2/account/<account_name>/deployment/<uid>/zookeeper-config/?page=<n>

where <account_name> is the name of the tenant account, and <uid> is the ID of the deployment. The query parameter page is a number, <n>, that defaults to 1.

This method uses either Token authentication or API Key authentication.

There is no request body.

When invoked from Linux (Bash script):

curl --request GET "https://app.searchstax.com/api/rest/v2/account/<account_name>/deployment/<uid>/zookeeper-config/?page=<n>" \
  --header "Authorization: APIkey <apikey>" 

When invoked from Windows (PowerShell script):

$ACCOUNT = "AccountName"
$uid = "ss123456"

$RESULTS = Invoke-RestMethod -Method Get -Headers $headers `
          -uri "https://app.searchstax.com/api/rest/v2/account/$ACCOUNT/deployment/$uid/zookeeper-config/" 
$RESULTS = $RESULTS | ConvertTo-Json

The response is a JSON document containing a list of Zookeeper configurations.

{
    "configs":  [
                    "_default",
                    "film"
                ],
    "success":  "true"
}

account > deployment > zookeeper-config > create

Will not overwrite existing configset.

account > deployment > zookeeper-config > create cannot overwrite an existing configset. It returns a 400 Error in that situation.

This is unlike zkcli, which does overwrite existing configs.

This method lets you upload a configset to the Zookeeper ensemble of a deployment.

POST /api/rest/v2/account/<account_name>/deployment/<uid>/zookeeper-config/

where <account_name> is the name of the tenant account, and <uid> is the ID of the deployment.

This method uses either Token authentication or API Key authentication.

The request body should be a “multipart/form-data” encoded object, containing the following items:

Parameter Description Example
name
required
string
This is the name of the new Zookeeper config. “text_config”
files
required
file
The value here is the path to a zip file of the contents of a local config directory. @conf.zip

The config files are uploaded as a zip file including the contents of the configuration directory but not the directory itself. The zip file should contain all configuration files, including subfolders.

SearchStax Provisioning API

When invoked from Linux (Bash script), use the -F, –form <name=content> param to specify name and files. This enables uploading of binary files. To force the zip file to be uploaded as a binary file, prefix the file name with an “@” character.

curl -H "Authorization: APIkey <apikey>" \
   -X POST \
   -F "name=test_config" \
   -F "files=@conf.zip" \
   https://app.searchstax.com/api/rest/v2/account/<account_name>/deployment/<uid>/zookeeper-config/

When invoked from Windows (PowerShell script), use a version of PowerShell that supports multipart-form data, such as PowerShell Core 6.1+ or Powershell 7.0+. To determine what version of PowerShell you are running, evaluate $PSVersionTable.PSVersion.

$ACCOUNT = "AccountName"
$uid = "ss123456"

$form = @{
    name = 'test_config'
    files = Get-Item -Path 'conf.zip'
}

# Assuming the zipped config file is in the same directory as this script. 

$RESULTS = Invoke-RestMethod -Method Post -Form $form -Headers $headers `
          -uri "https://app.searchstax.com/api/rest/v2/account/$ACCOUNT/deployment/$uid/zookeeper-config/" 
$RESULTS = $RESULTS | ConvertTo-Json

The response is a JSON document containing a list of the deployment’s current configsets.

{
  "configs": [
    "_default",
    "film",
    "test_config"
  ],
  "success": "true"
}

account > deployment > zookeeper-config > read

This method returns a list of config files from a named configuration in the Zookeeper ensemble of a deployment.

GET /api/rest/v2/account/<account_name>/deployment/<uid>/zookeeper-config/<name>/

where <account_name> is the name of the tenant account, and <uid> is the ID of the deployment. The <name> is the name of a configuration within Zookeeper.

This method uses either Token authentication or API Key authentication.

There is no request body.

When invoked from Linux (Bash script):

curl --request GET "https://app.searchstax.com/api/rest/v2/account/<account_name>/deployment/<uid>/zookeeper-config/<name>/" \
  --header "Authorization: APIkey <apikey>" 

When invoked from Windows (PowerShell script):

$ACCOUNT = "AccountName"
$uid = "ss123456"

$RESULTS = Invoke-RestMethod -Method Get -Headers $headers `
          -uri "https://app.searchstax.com/api/rest/v2/account/$ACCOUNT/deployment/$uid/zookeeper-config/$NAME/" 
$RESULTS = $RESULTS | ConvertTo-Json

The response is a JSON document containing a list of all files in the configset.

{
  "configs": [
    "film/lang/hyphenations_ga.txt",
    "film/lang/stopwords_hu.txt",
    "film/lang/stopwords_el.txt",
    "film/lang/stopwords_no.txt",
    "film/lang/stopwords_ca.txt",
    "film/lang/stopwords_de.txt",
    "film/lang/stopwords_sv.txt",
    "film/stopwords.txt",
    "film/lang/contractions_ca.txt",
    "film/lang/stopwords_ro.txt",
    "film/lang/stopwords_bg.txt",
    "film/solrconfig.xml",
    "film/lang/stopwords_ga.txt",
    "film/lang/stopwords_en.txt",
    "film/lang/stopwords_es.txt",
    "film/lang/stopwords_gl.txt",
    "film/lang/stopwords_fi.txt",
    "film/lang/contractions_fr.txt",
    "film/lang/stopwords_da.txt",
    "film/lang/stopwords_fa.txt",
    "film/lang/stopwords_nl.txt",
    "film/lang/stopwords_it.txt",
    "film/lang/stopwords_pt.txt",
    "film/params.json",
    "film/protwords.txt",
    "film/lang/stoptags_ja.txt",
    "film/lang/userdict_ja.txt",
    "film/lang/stopwords_tr.txt",
    "film/lang/stopwords_ru.txt",
    "film/lang/contractions_ga.txt",
    "film/synonyms.txt",
    "film/lang/stopwords_fr.txt",
    "film/lang/stopwords_ar.txt",
    "film/lang/stopwords_eu.txt",
    "film/lang/stopwords_th.txt",
    "film/lang/stopwords_hy.txt",
    "film/lang/stopwords_lv.txt",
    "film/lang/stemdict_nl.txt",
    "film/lang/contractions_it.txt",
    "film/lang/stopwords_hi.txt",
    "film/lang/stopwords_ja.txt",
    "film/lang/stopwords_cz.txt",
    "film/managed-schema",
    "film/lang/stopwords_id.txt"
  ],
  "name": "test_config",
  "success": "true"
}

account > deployment > zookeeper-config > delete

This method deletes a configset from the Zookeeper ensemble of a deployment.

DELETE /api/rest/v2/account/<account_name>/deployment/<uid>/zookeeper-config/<name>/

where <account_name> is the name of the tenant account, and <uid> is the ID of the deployment. The <name> is the name of a configuration within Zookeeper.

This method uses either Token authentication or API Key authentication.

There is no request body.

When invoked from Linux (Bash script):

curl --request DELETE "https://app.searchstax.com/api/rest/v2/account/<account_name>/deployment/<uid>/zookeeper-config/<name>/" \
  --header "Authorization: APIkey <apikey>" 

When invoked from Windows (PowerShell script):

$ACCOUNT = "AccountName"
$uid = "ss123456"
$NAME = "ConfigName"

$RESULTS = Invoke-RestMethod -Method Delete -Headers $headers `
          -uri "https://app.searchstax.com/api/rest/v2/account/$ACCOUNT/deployment/$uid/zookeeper-config/$NAME/" 
$RESULTS = $RESULTS | ConvertTo-Json

The response is a JSON document containing a confirmation message.

{
    "message":  "Config test_config has been deleted.",
    "success":  "true"
}

account > deployment > zookeeper-config > download

This method downloads a configset from the Zookeeper ensemble of a deployment in the form of a zip file.

GET /api/rest/v2/account/<account_name>/deployment/<uid>/zookeeper-config/<name>/download/

where <account_name> is the name of the tenant account, and <uid> is the ID of the deployment. The <name> is the name of a configuration within Zookeeper.

This method uses either Token authentication or API Key authentication.

There is no request body.

When invoked from Linux (Bash script):

curl --request GET "https://app.searchstax.com/api/rest/v2/account/<account_name>/deployment/<uid>/zookeeper-config/<name>/download/" \
  --header "Authorization: APIkey <apikey>" 
  -o "filename.zip"

Note the -o “filename.zip” parameter in cURL. This captures the downloaded zip file and writes it to the current directory.

When invoked from Windows (PowerShell script):

$ACCOUNT = "AccountName"
$uid = "ss123456"
$NAME = "ConfigName"

$RESULTS = Invoke-RestMethod -outfile "$NAME.zip" -Method Get -Headers $headers `
          -uri "https://app.searchstax.com/api/rest/v2/account/$ACCOUNT/deployment/$uid/zookeeper-config/$NAME/download/" 
Write-Host "Look for $NAME.zip in current directory."

Note the -outfile “$NAME.zip” parameter in Invoke-RestMethod. This captures the downloaded zip file and writes it to the current directory.

The response is a zip file containing the configset files from Zookeeper.

Questions?

Do not hesitate to contact the SearchStax Support Desk.