> ## Documentation Index
> Fetch the complete documentation index at: https://doc.lucidworks.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Collections API

> Fusion Admin APIs

export const LwTemplate = ({title = "Key questions to get you started", icon = "sparkles", cta = "Powered by Agent Studio", linkHref = "https://lucidworks.com/demo/?utm_source=docs&utm_medium=referral&utm_campaign=docs_cta_ai"}) => {
  const [isLoaded, setIsLoaded] = useState(false);
  useEffect(() => {
    const timer = setTimeout(() => {
      setIsLoaded(true);
    }, 500);
    return () => clearTimeout(timer);
  }, []);
  return <div className="lw-template-container">
      <Card title={title} icon={icon}>
        {isLoaded && <span dangerouslySetInnerHTML={{
    __html: `<lw-template id="a029c1a9-28be-427e-b0e1-5d918920246a"></lw-template
            >`
  }} />}
        <Link href={linkHref} className="agent-studio-link text-left text-gray-600 gap-2 dark:text-gray-400 text-sm font-medium flex flex-row items-center hover:text-primary dark:hover:text-primary-light group-hover:text-primary group-hover:dark:text-primary-light">Powered by Lucidworks Agent Studio</Link>
      </Card>
    </div>;
};

[localhost link]: http://localhost:3000/docs/5/fusion/dev-portal/api/api-swagger/collections-api

[mintlify link]: https://doc.lucidworks.com/docs/5/fusion/dev-portal/api/api-swagger/collections-api

[old doc.lw link]: https://doc.lucidworks.com/fusion/5.9/307

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.

For more information, [view the API specification.](/api-reference/collections/get-collections-service-status)

<LwTemplate />

## Data commit functionality

Solr offers three methods to determine when newly-indexed documents are made visible in searches. The methods are manual commits, auto commit settings, and the per-update `commitWithin` parameter.

Fusion relies on Solr's commit mechanisms, but adds a Fusion-managed `commitWithin` policy per collection. Fusion's typical commit configuration includes:

* The `autoCommit` setting (Solr hard commit) is inherited from the collection's `solrconfig.xml` and is typically set to `15` seconds with `openSearcher=false`. This persists data to disk at that interval without opening a new searcher, which helps maintain search performance.

* The `autoSoftCommit` setting (Solr soft commit) is turned off by default, with Fusion relying on the `commitWithin` setting to make data visible to searches.

* Solr's `commitWithin` parameter configured at the collection level with a default of `10000` milliseconds, ensures data is committed and available for searching within 10 seconds. The default for signals collections is `1000` milliseconds. Fusion uses `commitWithin` to avoid relying on specific Solr-side configurations. The `com.lucidworks.apollo.solr.commitWithin` global property defines the default `commitWithin` for all documents added through Fusion. When you create a new collection in Fusion, its per-collection `commitWithin` is initialized from this global default.

## Examples

<Note>
  In order to see this object within the [Fusion UI](/docs/5/fusion/intro/ui-tour/object-explorer), it **must** be associated with an app. To do this, create the object using the `/apps` endpoint.
</Note>

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

**REQUEST**

```bash wrap  theme={"dark"}
curl -u USERNAME:PASSWORD -X POST -H 'Content-type: application/json' -d '{"name": "newCollection","solrParams":{"replicationFactor":1,"numShards":1}}' https://FUSION_HOST:FUSION_PORT/api/collections
```

**RESPONSE**

```json wrap  theme={"dark"}
{
  "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':*

**REQUEST**

```bash wrap  theme={"dark"}
curl -u USERNAME:PASSWORD -X POST -H 'Content-type: application/json' -d '{"id":"local-collection1", "searchClusterId":"Solr4.10", "solrParams":{"name":"collection1"}}' https://FUSION_HOST:FUSION_PORT/api/collections
```

**RESPONSE**

```json wrap  theme={"dark"}
{
  "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**

```bash wrap  theme={"dark"}
curl -u USERNAME:PASSWORD -X DELETE https://FUSION_HOST:FUSION_PORT/api/collections/newCollection?purge=false
```

*Get the status of the 'demo' collection:*

**REQUEST**

```bash wrap  theme={"dark"}
curl -u USERNAME:PASSWORD https://FUSION_HOST:FUSION_PORT/api/collections/demo/status
```

**RESPONSE**

```json wrap  theme={"dark"}
{
  "maxShardsPerNode" : 1,
  "replicationFactor" : 1,
  "shards" : {
    "shard1" : {
      "range" : "80000000-7fffffff",
      "state" : "active",
      "replicas" : {
        "core_node1" : {
          "state" : "active",
          "core" : "demo_shard1_replica1",
          "leader" : true,
          "base_url" : "https://FUSION_HOST:8983/solr",
          "node_name" : "FUSION_HOST:8983_solr"
        }
      }
    }
  }
}
```

*Get stats for the 'demo' collection:*

**REQUEST**

```bash wrap  theme={"dark"}
curl -u USERNAME:PASSWORD https://FUSION_HOST:FUSION_PORT/api/collections/demo/stats
```

**RESPONSE**

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

*Add the recommendations feature for the 'tempy' collection:*

<Note>
  For more information on collection features and feature management, see [Collection Features API](/docs/5/fusion/dev-portal/api/api-swagger/collection-features-api)
</Note>

Use this structure to send the request:

```sh wrap  theme={"dark"}
https://FUSION_HOST:FUSION_PORT/api/collections/{collection}/features/{feature}
```

```bash wrap  theme={"dark"}
curl -u USERNAME:PASSWORD -X POST -H 'Content-type: application/json' -d @enable-recommendations.json https://FUSION_HOST:FUSION_PORT/api/apps/Recommender-App/collections/tempy/features/recommendations -v
```

Make sure to change the `collection-id` in the JSON and save as a file or send directly in the string.

**Recommendations JSON:**

```json wrap  theme={"dark"}
{
"name": "recommendations",
"collectionId": "tempy",
"params":

{ "idField": "id", "itemsForUser": true, "itemsForQuery": false, "itemsForItem": true, "queriesForQuery": false }
,
"enabled": true
}
```

**Signals JSON:**

```json wrap  theme={"dark"}
{
"name": "signals",
"collectionId": "tempy",
"params": {},
"enabled": false
},
```

**Search Logs JSON:**

```json wrap  theme={"dark"}
{
"name": "searchLogs",
"collectionId": "tempy",
"params": {},
"enabled": false
}
```

**Partition by time JSON:**

```json wrap  theme={"dark"}
{
"name": "partitionByTime",
"collectionId": "tempy",
"params": {},
"enabled": false
}
```
