API - Enable or Disable Query Elevation

Index Management
Index Management API

Enable or Disable Query Elevation

Switches Query Elevation on or off for an index. Enabling patches the Solr configuration for you (component, request handler, elevate.xml) and reloads the index; disabling turns the feature off in your Opensolr account without touching the config files.

Endpoint

GET or POST https://opensolr.com/solr_manager/api/elevation_toggle

Parameters

ParameterStatusDescription
emailRequiredYour Opensolr registration email address
api_keyRequiredYour Opensolr API key (master key, or a scoped key that allows this endpoint)
core_nameRequiredThe index to configure
enableRequiredyes to enable, no to disable — any other value is rejected

How It Works

enable=yes reads your solrconfig.xml and search.xml on the Solr server. If the QueryElevationComponent is missing it is added; if the /select handler has no elevator last-component it is added; an empty elevate.xml is created when absent. Existing configs are patched in place, never replaced, and the index is reloaded at the end. Running it twice is safe — the second call reports nothing to change.

enable=no only flips the elevation_enabled flag for the index; the Solr config keeps the component so re-enabling is instant.

Once enabled, pin and exclude documents per query from the index Tools page or directly on the hosted search page (how it works).

Response

KeyTypeDescription
statusbooltrue on success
msgarrayOne entry per change applied, e.g. Added QueryElevationComponent to solrconfig.xml, Added elevator to search.xml, Core reloaded — or Elevation disabled
on error{"status":false,"msg":"Invalid enable value — must be yes or no"} or Could not read solrconfig.xml

Code Examples

$_ cURL

curl -s "https://opensolr.com/solr_manager/api/elevation_toggle?email=YOUR_EMAIL&api_key=YOUR_API_KEY&core_name=my_index&enable=yes"

PHP PHP

$q = http_build_query(['email' => 'YOUR_EMAIL', 'api_key' => 'YOUR_API_KEY', 'core_name' => 'my_index', 'enable' => 'yes']);
$r = json_decode(file_get_contents("https://opensolr.com/solr_manager/api/elevation_toggle?{$q}"), true);
foreach ($r['msg'] as $change) { echo $change, "\n"; }

Py Python

import requests

r = requests.post("https://opensolr.com/solr_manager/api/elevation_toggle", data={
    "email": "YOUR_EMAIL", "api_key": "YOUR_API_KEY", "core_name": "my_index", "enable": "yes"}, timeout=60)
print(r.json())

Example Response

{
  "status": true,
  "msg": [
    "Added QueryElevationComponent to solrconfig.xml",
    "Added elevator to search.xml",
    "Core reloaded"
  ]
}

Use Cases

  • Enable elevation from a deployment script right after creating an index
  • Expose an “Enable Query Elevation” switch in your own CMS admin (the Drupal module and WordPress plugin call this endpoint)
  • Temporarily disable curated results during a content migration

Related Documentation

Need help with the Opensolr API? We are here to help.

Contact Support