Index Management
Index create/update/patch operations should only be used if you are using the self-hosted version of Searchcraft. Index operations for Searchcraft Cloud are managed via the Vektron UI.
API Endpoints
Section titled “API Endpoints”GET /indexReturns a list of all indexes.GET /index/statsReturns document counts for every index on the instance.GET /index/:index_nameReturns the schema for an index.GET /index/:index_name/statsReturns meta data about an index such as the number of documents.POST /indexCreates or updates an index. Expects a schema definition object in the request body. This will empty your index if it exists and has documents.PATCH /index/:index_nameAllows you to make a partial configuration change to an index schema without having to re-ingest all of your data. Updates are limited tosearch_fields,weight_multipliers,language,time_decay_field,auto_commit_delayandexclude_stop_wordssettings. Unlike the other index endpoints, the payload values should not be nested inside anindexobject.PUT /index/:index_nameReplace the contents. Expects a schema definition object in the request body. Same payload asPOST /index. If the index does not exist you will receive a 404.DELETE /index/:index_nameDeletes an index.
Auth Requirement
Section titled “Auth Requirement”Requires an authentication key that has permissions to access the endpoint. For endpoints containing an index name, this is an ingest key. For creation endpoints, this is an admin key.
Schema creation
Section titled “Schema creation”Payload to create an index on a self-hosted instance of Searchcraft. See the schema configuration reference for more information on the properties.
Example Schema
Section titled “Example Schema”{ "index": { "auto_commit_delay": 1, "language": "en", "name": "creation_test", "search_fields": [ "title", "body" ], "fields": { "id": { "type": "text", "required": true, "stored": true, "indexed": false }, "created_at": { "type": "datetime", "fast": true, "stored": true, "indexed": true }, "title": { "type": "text", "stored": true }, "body": { "type": "text", "stored": true }, "active": { "type": "bool", "fast": true, "stored": true }, "rating": { "type": "f64", "stored": true, "fast": true }, "reviews": { "type": "u64", "stored": true, "fast": true }, "tags": { "type": "text", "stored": true, "multi": true }, "category": { "type": "facet", "stored": true }, "formats": { "type": "facet", "stored": true, "multi": true } }, "weight_multipliers": { "title": 2, "body": 0.7 } }}Example CURL Request to create an index
Section titled “Example CURL Request to create an index”override_if_exists- Optional boolean value that dictates whether or not the POST request will override the existing index if it already exists. Defaults tofalse.index- The index schema. See the schema configuration reference.
curl -X POST \ -H "Content-Type: application/json" \ --data '{ "override_if_exists": true, "index": { "name": "creation_test", "search_fields": [ "title", "body" ], "fields": { "id": { "type": "text", "required": true, "stored": true, "indexed": false }, "created_at": { "type": "datetime", "fast": true, "stored": true, "indexed": true }, "title": { "type": "text", "stored": true }, "body": { "type": "text", "stored": true }, "active": { "type": "bool", "fast": true, "stored": true }, "rating": { "type": "f64", "stored": true, "fast": true }, "reviews": { "type": "u64", "stored": true, "fast": true }, "tags": { "type": "text", "stored": true, "multi": true }, "category": { "type": "facet", "stored": true }, "formats": { "type": "facet", "stored": true, "multi": true } }, "weight_multipliers": { "title": 2, "body": 0.7 } } }' \ http://yoursearchcrafthost/indexDelete this example index
Section titled “Delete this example index”curl -X DELETE -H "Content-Type: application/json" http://yoursearchcrafthost/index/creation_test/Response from stats endpoint
Section titled “Response from stats endpoint”{ "status": 200, "data": { "document_count": 541 }}