Merge & Split

In case you are interested in changing the clusters created automatically by the AI engine, you can split or merge them. For both actions you need to know the cluster_id - see Get Clusters in Collection.

Merge Clusters

In order to merge clusters, be it two or more, use the following API, providing it with the relevant details:

curl -X POST \
'https://api.oneai.com/clustering/v1/collections/<collection-name>/merge' \
-H 'accept: application/json' \
-H 'Content-Type: application/json' \
-H 'api-key: <YOUR-API-KEY-HERE>' \
--d '{"source_clusters":["<CLUSTER ID>","<CLUSTER ID>"],
    "destination_cluster":"<CLUSTER ID>"}'
import requests
import json

url = "https://api.oneai.com/clustering/v1/collections/<COLLECTION NAME>/merge"

payload = json.dumps({
  "source_clusters": [
    "<CLUSTER ID>",
    "<CLUSTER ID>"
  ],
  "destination_cluster": "<CLUSTER ID>"
})
headers = {
  'api-key': '<YOUR API KEY>',
  'Content-Type': 'application/json'
}

response = requests.request("POST", url, headers=headers, data=payload)

print(response.text)

var request = require('request');
var options = {
  'method': 'POST',
  'url': 'https://api.oneai.com/clustering/v1/collections/<COLLECTION NAME>/merge',
  'headers': {
    'api-key': '<YOUR API KEY>',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    "source_clusters": [
      "<CLUSTER ID>",
      "<CLUSTER ID>"
    ],
    "destination_cluster":"<CLUSTER ID>"
  })

};
request(options, function (error, response) {
  if (error) throw new Error(error);
  console.log(response.body);
});

Note this function could be used to merge a few clusters into one of them, but also to merge a few clusters into a completely different cluster.

Split Phrases

In order to split a cluster, use the following API, providing it with the relevant details:

curl -X 'POST' \
  'https://api.oneai.com/clustering/v1/collections/<collection-name>/phrases/<phrase_id>/split'\
  -H 'accept: application/json' \
  -H 'api-key: <YOUR-API-KEY-HERE>'
var request = require('request');
var options = {
  'method': 'POST',
  'url': 'https://api.oneai.com/clustering/v1/collections/<COLLECTION NAME>/phrases/<PHRASE ID>/split',
  'headers': {
    'api-key': '<YOUR API KEY>'
  }
};
request(options, function (error, response) {
  if (error) throw new Error(error);
  console.log(response.body);
});

import requests

url = "https://api.oneai.com/clustering/v1/collections/<COLLECTION NAME>/phrases/<PHRASE ID>/split"

payload = ""
headers = {
  'api-key': '<YOUR API KEY>'
}

response = requests.request("POST", url, headers=headers, data=payload)

print(response.text)