Terms
Terms
Terms are the fundamental building blocks in a taxonomy. They are used to create hierarchical structures and are integrated into entries to classify and categorize information systematically.
addParam
The addParam method adds a parameter to a collection using a key-value pair.
| Name | Type | Description |
|---|---|---|
| key (required) | string | The key of the parameter |
| value (required) | Object | The value of the parameter |
import contentstack;
Contentstack contentstack = new Contentstack.Builder().build();
Terms terms = contentstack.terms();
terms.addParam("key", "value");addHeader
The addHeader method adds a header with a key-value pair to a request.
| Name | Type | Description |
|---|---|---|
| key (required) | string | The key of the parameter |
| value (required) | string | The value of the parameter |
import contentstack;
Contentstack contentstack = new Contentstack.Builder().build();
Terms terms = contentstack.terms();
terms.addHeader("key", "value");addParams
The addParams method takes a HashMap of String keys and Object values as input and returns a generic type T.
| Name | Type | Description |
|---|---|---|
| params (required) | HashMap | Maps String keys to Object values |
import contentstack;
Contentstack contentstack = new Contentstack.Builder().build();
Terms terms = contentstack.terms();
terms.addParams("params");addHeaders
The addHeaders method adds headers to a HashMap.
| Name | Type | Description |
|---|---|---|
| headers (required) | HashMap | A HashMap containing key-value pairs of headers |
import contentstack;
Contentstack contentstack = new Contentstack.Builder().build();
Terms terms = contentstack.terms();
terms.addHeaders("headers");create
The create method lets you add a term to the taxonomy.
| Name | Type | Description |
|---|---|---|
| body (required) | JSON Object | The request body to be sent in the call |
Stack stack = new Contentstack.Builder().build().stack(headers);
JSONObject body = new JSONObject();
Term term = stack.taxonomy("taxonomyId").terms().create(body);find
The find method retrieves th elist of all terms in the taxonomy.
| Name | Type | Description |
|---|---|---|
| taxonomy_uid (required) | string | The UID Of the taxonomy for which we need the terms. |
| depth | boolean | Include the terms upto the depth specified if set to a number greater than 0, include all the terms if set to 0, default depth will be set to 1 |
| include_children_count | boolean | Include count of number of children under each term |
| include_referenced_entries_count | boolean | Include count of the entries where this term is referred |
| include_count | boolean | Include count of the documents/nodes that matched the query |
| asc|desc | string | Sort the given field in either ascending or descending order |
| typeahead | boolean | Used to match the given string in all terms and return the matched result |
| deleted | boolean | Used to fetch only the deleted terms |
| skip | number | Skip the number of documents/nodes |
| limit | number | Limit the result to number of documents/nodes |
Stack stack = new Contentstack.Builder().build().stack(headers);
Term term = stack.taxonomy("taxonomyId").terms().addParam("limit", 2).find();fetch
The fetch method retrieves the information about a specific term in the taxonomy.
| Name | Type | Description |
|---|---|---|
| termUid (required) | string | The UID Of the term |
| include_children_count | boolean | Include count of number of children under each term |
| include_referenced_entries_count | boolean | Include count of the entries where this term is referred |
Stack stack = new Contentstack.Builder().build().stack(headers);
Term term = stack.taxonomy("taxonomyId").terms().find();descendants
The descendants method retrieves the information about the descendants of a specific term in the taxonomy.
| Name | Type | Description |
|---|---|---|
| termUid (required) | string | The UID Of the term |
| depth | boolean | Include the terms upto the depth specified if set to a number greater than 0, include all the terms if set to 0, default depth will be set to 1 |
| include_children_count | boolean | Include count of number of children under each term |
| include_referenced_entries_count | boolean | Include count of the entries where this term is referred |
| include_count | boolean | Include count of the documents/nodes that matched the query |
| skip | number | Skip the number of documents/nodes |
| limit | number | Limit the result to number of documents/nodes |
Stack stack = new Contentstack.Builder().build().stack(headers);
Term term = stack.taxonomy("taxonomyId").terms().descendants("termId");ancestors
The ancestors method retrieves the information about the ancestors of a specific term in the taxonomy.
| Name | Type | Description |
|---|---|---|
| termUid (required) | string | The UID Of the term |
Stack stack = new Contentstack.Builder().build().stack(headers);
Term term = stack.taxonomy("taxonomyId").terms().ancestors("termId");update
The update method lets you update the details of an existing term in the taxonomy.
| Name | Type | Description |
|---|---|---|
| termUid (required) | string | The UID Of the term |
| body (required) | JSONObject | The request body to be sent in the call |
body = new RequestBody{
"term": {
"name": "Term 1",
"description": "Term 1 Description updated for Taxonomy 1"
}
}
Stack stack = new Contentstack.Builder().build().stack(headers);
Term term = stack.taxonomy("taxonomyId").terms().update(body);search
The search method retrieves the details of different terms in the taxonomy.
| Name | Type | Description |
|---|---|---|
| termString (required) | string | The string of the UIDs/names of the terms |
Stack stack = new Contentstack.Builder().build().stack(headers);
Term term = stack.taxonomy("taxonomyId").terms().search("search anything");