API Endpoint
Optimize Solr Index
Optimization merges all index segments into one, improving search performance and reclaiming disk space from deleted documents. This operation runs asynchronously in the background — the API returns immediately while optimization continues on the server.
Endpoint
GET https://opensolr.com/solr_manager/api/optimize
Parameters
| Parameter | Status | Description |
|---|---|---|
email | required | Your Opensolr registration email address |
api_key | required | Your Opensolr API key |
core_name | required | The name of the index you wish to optimize |
Important:
- Your index may temporarily double in size on disk during optimization
- This can take a long time for large indexes
- Avoid writing to the index while optimization is running
- The index remains fully searchable during optimization
Response
{"status":true,"msg":"Optimization started. This runs in the background and may take a while for large indexes."}
Use the Check Optimize Status endpoint to monitor progress.
Code Examples
cURL
curl -s "https://opensolr.com/solr_manager/api/optimize?email=YOUR_EMAIL&api_key=YOUR_API_KEY&core_name=YOUR_INDEX"
PHP
$params = http_build_query([ 'email' => 'YOUR_EMAIL', 'api_key' => 'YOUR_API_KEY', 'core_name' => 'YOUR_INDEX', ]); $response = json_decode(file_get_contents( 'https://opensolr.com/solr_manager/api/optimize?' . $params ), true); if ($response['status']) { echo "Optimization started!\n"; }
Python
import requests response = requests.get( "https://opensolr.com/solr_manager/api/optimize", params={ "email": "YOUR_EMAIL", "api_key": "YOUR_API_KEY", "core_name": "YOUR_INDEX", } ) data = response.json() if data["status"]: print("Optimization started!")
Related Documentation
Check Optimize Status
Monitor the progress of a running optimization.
Commit Data
Commit pending data to make it searchable.
Index Full Status
Get the full status of your Solr index.
Need help managing your Solr indexes? We are here to help.
Contact Support