Collections API

The Collections API manages Fusion collections. It provides endpoints for creating, updating, and deleting collection, as well as endpoints for getting a collection’s status and usage statistics.

Fusion maintains internal system collections for logs, blobs, and metrics data which operate in conjunction with collections created by users. The Collections API is used to manage all Fusion collections.

Create, List, Update or Delete Collections

The path for this request is:

/api/apollo/collections/<name>

where <name> is the name of an specific collection.

  • GET - returns properties for the specified collection or properties for all collections if no collection name is specified.

  • PUT - create or update a collection

  • DELETE - remove a collection. A DELETE request takes two parameters:

    • solr - if true, the collection will be deleted from Solr while it is deleted from Fusion. The default is false.

    • purge - if true, then associated signals and/or searchLogs collections will also be deleted. The default is false.

Collections properties

The body of a PUT request contains the following properties, specified in JSON:

Property Description

searchClusterId
Optional

The name of the search cluster to associate the collection with. If this is not defined, "default" will be used, which is the name of the LucidWorks cluster at installation. See also the section on Search Clusters for more information.

solrParams

A set of name:value pairs corresponding to the properties avaliable on a Solr collection. See Solr’s collection API documentation for a list of valid parameters.

type
Optional

The type of collection. The type must be one of the following:

  • DATA

  • LOGS

  • METRICS

  • SIGNALS

  • SEARCHLOGS

If not defined, the type will default to "DATA", which is fine for most cases.

metadata

This is an internal property, and will be removed in the future.

Get Collection Status or Statistics

A GET request to endpoint:

/api/apollo/collections/<name>/status

returns a listing of state of each shard and all of its replicas, including the core name, its status as leader, the base URL and the node name.

A GET request to endpoint:

/api/apollo/collections/<name>/stats

returns a more detailed listing, including the number of documents in the index, how many requests have been made of the collection, the queries-per-second (qps) and the index size in bytes.

Examples

Create a new collection called 'newCollection', with appropriate SolrCloud environment settings:

REQUEST

curl -u user:pass -X PUT -H 'Content-type: application/json' -d '{"solrParams":{"replicationFactor":1,"numShards":1}}' http://localhost:8764/api/apollo/collections/newCollection

RESPONSE

{
  "id" : "newCollection",
  "createdAt" : "2014-09-19T18:46:52.954Z",
  "searchClusterId" : "default",
  "solrParams" : {
    "name" : "newCollection",
    "numShards" : 1,
    "replicationFactor" : 1
  },
  "type" : "DATA",
  "metadata" : { }
}

Create a collection named 'local-collection1' that refers to 'collection1' in a pre-existing SolrCloud cluster named 'Solr4.10' (see also the section Search Clusters):

REQUEST

curl -u user:pass -X POST -H 'Content-type: application/json' -d '{"id":"local-collection1", "searchClusterId":"Solr4.10", "solrParams":{"name":"collection1"}}' http://localhost:8764/api/apollo/collections

RESPONSE

{
  "id" : "local-collection1",
  "createdAt" : "2014-09-19T18:48:45.396Z",
  "searchClusterId" : "Solr4.10",
  "solrParams" : {
    "name" : "collection1"
  },
  "type" : "DATA",
  "metadata" : { }
}

Delete a collection, but keep the associated signals and searchLogs collections:

REQUEST

curl -u user:pass -X DELETE http://localhost:8764/api/apollo/collections/newCollection?purge=false

Get the status of the 'demo' collection:

REQUEST

curl -u user:pass http://localhost:8764/api/apollo/collections/demo/status

RESPONSE

{
  "maxShardsPerNode" : 1,
  "replicationFactor" : 1,
  "shards" : {
    "shard1" : {
      "range" : "80000000-7fffffff",
      "state" : "active",
      "replicas" : {
        "core_node1" : {
          "state" : "active",
          "core" : "demo_shard1_replica1",
          "leader" : true,
          "base_url" : "http://localhost:8983/solr",
          "node_name" : "localhost:8983_solr"
        }
      }
    }
  }
}

Get stats for the 'demo' collection:

REQUEST

curl -u user:pass http://localhost:8764/api/apollo/collections/demo/stats

RESPONSE

{
  "collectionId" : "demo",
  "documentCount" : 536,
  "requestCount" : 6,
  "qps" : 28.34716542561849,
  "sizeInBytes" : 7646045,
  "lastModified" : "2014-05-19T19:58:33.545Z"
}