TermQuery
TermQuery
The TermQuery class provides a fluent builder for querying published terms within a taxonomy from the CDA.
Note There's no public constructor. Obtain a TermQuery only through stack.Taxonomies(uid).Terms(), which already guarantees a valid taxonomy UID.
SetLocale
The SetLocale method filters the terms returned by Find to those published in the specified locale. Passing a null or empty value is treated as a no-op.
| Name | Type | Description |
|---|---|---|
| locale | string | Locale code to filter by (for example, "hi-in" or "en-us") |
Validation
No exception is thrown for a null or empty locale. It's treated as a no-op.
Behavior
Client-side only. Sets a pending query parameter. No HTTP call is made until Find is called.
Example
ContentstackClient stack = new ContentstackClient("api_key", "delivery_token", "environment");
var result = await stack.Taxonomies("taxonomy_uid").Terms().SetLocale("hi-in").Find<MyTerm>();IncludeFallback
The IncludeFallback method returns terms in the master locale for any term not published in the requested locale. It can be used with or without SetLocale.
Validation
Takes no parameters, so there's nothing to validate.
Behavior
Client-side only. Unconditionally sets include_fallback=true as a pending query parameter. No HTTP call is made until Find is called.
Example
ContentstackClient stack = new ContentstackClient("api_key", "delivery_token", "environment");
var result = await stack.Taxonomies("taxonomy_uid").Terms().SetLocale("hi-in").IncludeFallback().Find<MyTerm>();AddParam
The AddParam method adds a custom query parameter to the terms request. Chain this method before calling Find.
| Name | Type | Description |
|---|---|---|
| key (required) | string | Query parameter key |
| value (required) | string | Query parameter value |
Validation
No SDK-level null check is performed on key or value.
Behavior
Client-side only. Sets an arbitrary pending query parameter. No HTTP call is made until Find is called.
Example
ContentstackClient stack = new ContentstackClient("api_key", "delivery_token", "environment");
var result = await stack.Taxonomies("taxonomy_uid").Terms().AddParam("include_branch", "true").Find<MyTerm>();Depth
The Depth method limits the depth of the term hierarchy returned by Find. Depth(1) returns only root-level terms, higher values include deeper levels. Chain this method before calling Find.
| Name | Type | Description |
|---|---|---|
| depth (required) | int | Maximum number of hierarchy levels to include |
Validation
No SDK-level validation is performed on depth.
Behavior
Client-side only. Sets a pending query parameter. No HTTP call is made until Find is called.
Example
ContentstackClient stack = new ContentstackClient("api_key", "delivery_token", "environment");
var result = await stack.Taxonomies("taxonomy_uid").Terms().Depth(1).Find<MyTerm>();IncludeBranch
The IncludeBranch method includes branch information in the response for each term. Chain this method before calling Find.
Validation
Takes no parameters, so there's nothing to validate.
Behavior
Client-side only. Unconditionally sets include_branch=true as a pending query parameter. No HTTP call is made until Find is called.
Example
ContentstackClient stack = new ContentstackClient("api_key", "delivery_token", "environment");
var result = await stack.Taxonomies("taxonomy_uid").Terms().IncludeBranch().Find<MyTerm>();Skip
The Skip method sets the number of terms to skip in the result set, for pagination offset. Chain this method before calling Find.
| Name | Type | Description |
|---|---|---|
| skip (required) | int | Number of terms to skip. Must be greater than or equal to 0 |
Validation
No SDK-level validation is performed on skip.
Behavior
Client-side only. Sets a pending query parameter. No HTTP call is made until Find is called.
Example
ContentstackClient stack = new ContentstackClient("api_key", "delivery_token", "environment");
var page2 = await stack.Taxonomies("taxonomy_uid").Terms().Skip(10).Limit(10).Find<MyTerm>();Limit
The Limit method sets the maximum number of terms to return. Chain this method before calling Find.
| Name | Type | Description |
|---|---|---|
| limit (required) | int | Maximum result count |
Validation
No SDK-level validation is performed on limit.
Behavior
Client-side only. Sets a pending query parameter. No HTTP call is made until Find is called.
Example
ContentstackClient stack = new ContentstackClient("api_key", "delivery_token", "environment");
var terms = await stack.Taxonomies("taxonomy_uid").Terms().Limit(5).Find<MyTerm>();IncludeCount
The IncludeCount method includes the total count of matching terms in the response. Chain this method before calling Find.
Validation
Takes no parameters, so there's nothing to validate.
Behavior
Client-side only. Unconditionally sets include_count=true as a pending query parameter. No HTTP call is made until Find is called. Access the count through the returned collection's Count property.
Example
ContentstackClient stack = new ContentstackClient("api_key", "delivery_token", "environment");
var result = await stack.Taxonomies("taxonomy_uid").Terms().IncludeCount().Find<MyTerm>();Find
The Find method executes the term query and returns all matching published terms for the taxonomy.
Validation
No additional validation is performed. The taxonomy UID was already guaranteed non-empty when this TermQuery was constructed through Taxonomy.Terms(). See Delivery API Errors for general request errors.
Behavior
Makes one HTTP GET request to /taxonomies/{uid}/terms. The response is unwrapped at the $.terms JSON token into the returned collection's Items.
Example
ContentstackClient stack = new ContentstackClient("api_key", "delivery_token", "environment");
ContentstackCollection<MyTerm> terms = await stack.Taxonomies("taxonomy_uid").Terms().SetLocale("hi-in").IncludeFallback().Find<MyTerm>();