Index management

You need to create an index after starting Cockatrice. Also you can delete indexes that are no longer needed.

Create an index

A schema is required to create an index, you need to put the schema in the request. Create an index by the following command:

$ curl -s -X PUT -H "Content-type: text/x-yaml" --data-binary @./conf/schema.yaml http://localhost:8080/indices/myindex | jq .

You can see the result in JSON format. The result of the above command is:

{
  "status": {
    "code": 202,
    "description": "Request accepted, processing continues off-line",
    "phrase": "Accepted"
  },
  "time": 0.3310730457305908
}

Get an index

If you created an index, you can retrieve index information by the following command:

$ curl -s -X GET http://localhost:8080/indices/myindex | jq .

The result of the above command is:

{
  "index": {
    "doc_count": 0,
    "doc_count_all": 0,
    "last_modified": 1545283032.1162639,
    "latest_generation": 0,
    "name": "myindex",
    "storage": {
      "files": [
        "_myindex_0.toc"
      ],
      "folder": "/tmp/cockatrice/index",
      "readonly": false,
      "supports_mmap": true
    },
    "version": -111
  },
  "status": {
    "code": 200,
    "description": "Request fulfilled, document follows",
    "phrase": "OK"
  },
  "time": 0.002009153366088867
}

Delete an index

You can delete indexes that are no longer needed. Delete an index by the following command:

$ curl -s -X DELETE http://localhost:8080/indices/myindex | jq .

You can see the result in JSON format. The result of the above command is:

{
  "status": {
    "code": 202,
    "description": "Request accepted, processing continues off-line",
    "phrase": "Accepted"
  },
  "time": 0.00032520294189453125
}