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 /index
Returns a list of all indexes.GET /index/stats
Returns document counts for every index on the instance.GET /index/:index_name
Returns the schema for an index.GET /index/:index_name/stats
Returns meta data about an index such as the number of documents.POST /index
Creates 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_name
Allows 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_delay
andexclude_stop_words
settings. Unlike the other index endpoints, the payload values should not be nested inside anindex
object.PUT /index/:index_name
Replace 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_name
Deletes 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”curl -X POST -H "Content-Type: application/json" --data '{"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/index
Delete 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 }}