---
title: "Taxonomy"
description: "Taxonomy"
url: "https://www.contentstack.com/docs/developers/sdks/content-delivery-sdk/java/reference/taxonomy"
product: "Contentstack"
doc_type: "guide"
audience:
  - developers
  - admins
version: "current"
last_updated: "2026-09-21"
---

# Taxonomy

## Taxonomy

Taxonomy helps you categorize pieces of content within your stack to facilitate easy navigation and retrieval of information.

To access the taxonomy instance, use the code snippet provided below within the stack class:

```
Stack stack = Contentstack.stack("API_KEY", "DELIVERY_TOKEN", "ENVIRONMENT");Taxonomy taxonomy = stack.taxonomy();
```

## in

The in method retrieves all entries for a specific taxonomy that satisfy the given conditions provided in the $in query.

```
Example: If you want to retrieve entries with the color taxonomy applied and linked to the terms red and/or yellow.
Taxonomy taxonomy = stack.taxonomy();List listOfItems = new ArrayList<>();
listOfItems.add("red");
listOfItems.add("yellow");
taxonomy.in("taxonomies.color", listOfItems).find(new TaxonomyCallback() {
            @Override
            public void onResponse(JSONObject response, Error error) {
                if (error!=null){
                    System.out.println("response :"+response);
                }
            }
        });
```

Enter the UID of the taxonomy

Enter the list of taxonomy fields

## or

The or method retrieves all entries for a specific taxonomy that satisfy at least one of the given conditions provided in the $or query.

```
Example: If you want to retrieve entries with either the color or size taxonomy applied and linked to the terms yellow and small, respectively.
Taxonomy taxonomy = stack.taxonomy();
     List<jsonobject>listOfItems = new ArrayList<>();
     JSONObject item1 = new JSONObject();
     item1.put("taxonomies.color", "yellow");
     JSONObject item2 = new JSONObject();
     item2.put("taxonomies.size", "small");
     listOfItems.add(item1);
     listOfItems.add(item2);
     taxonomy.or(listOfItems);
     taxonomy.find((response, error) -> {
        if (error!=null){
            System.out.println("response :"+response);
            }
        });
```

Enter the list of taxonomy fields

## and

The and method retrieves all entries for a specific taxonomy that satisfy all the conditions provided in the $and query.

```
Example: If you want to retrieve entries with the color and computers taxonomies applied and linked to the terms red and laptop, respectively.
Taxonomy taxonomy = stack.taxonomy();
List<jsonobject>listOfItems = new ArrayList<>();
JSONObject items1 = new JSONObject();
items1.put("taxonomies.color", "green");
JSONObject items2 = new JSONObject();
items2.put("taxonomies.computers", "laptop");
listOfItems.add(items1);
listOfItems.add(items2);
taxonomy.and(listOfItems);
taxonomy.find((response, error) -> {
  if (error!=null){
      System.out.println("response :"+response);
    }
  });
```

Enter the list of taxonomy fields

## exists

The exists method retrieves all entries for a specific taxonomy if the value of the field, mentioned in the condition, exists.

```
Example: If you want to retrieve entries with the color taxonomy applied.


Taxonomy taxonomy = stack.taxonomy().exists("taxonomies.color", true);
taxonomy.find(new TaxonomyCallback() {
            @Override
            public void onResponse(JSONObject response, Error error) {
                if (error!=null){
                    System.out.println("response :"+response);
                }
            }
        });
```

Enter the UID of the taxonomy

Enter true/false

## equalAndBelow

The equalAndBelow method retrieves all entries for a specific taxonomy that match a specific term and all its descendant terms, requiring only the target term.

```
Example: If you want to retrieve all entries with terms nested under blue, such as navy blue and sky blue, while also matching entries with the target term blue.


Taxonomy taxonomy = stack.taxonomy().equalAndBelow("taxonomies.color", "blue");
taxonomy.find(new TaxonomyCallback() {
            @Override
            public void onResponse(JSONObject response, Error error) {
                if (error!=null){
                    System.out.println("response :"+response);
                }
            }
        });
```

Enter the UID of the taxonomy

Enter the UID of the term

## equalAndBelowWithLevel

The equalAndBelowWithLevel method retrieves all entries for a specific taxonomy that match a specific term and all its descendant terms, requiring only the target term and a specified level.

**Note**: If you don't specify the level, the default behavior is to retrieve terms up to level 10.

```
Example: If you want to retrieve all entries until level 2 with terms nested under blue, such as navy blue and sky blue, while also matching entries with the target term blue.


Taxonomy taxonomy = stack.taxonomy().equalAndBelowWithLevel("taxonomies.color", "blue", 3);
taxonomy.find(new TaxonomyCallback() {
            @Override
            public void onResponse(JSONObject response, Error error) {
                if (error!=null){
                    System.out.println("response :"+response);
                }
            }
        });
```

Enter the UID of the taxonomy

Enter the UID of the term

Enter the level

## below

The below method retrieves all entries for a specific taxonomy that match all of their descendant terms by specifying only the target term and a specific level.

**Note**: If you don't specify the level, the default behavior is to retrieve terms up to level 10.

```
Example: If you want to retrieve all entries containing terms nested under blue, such as navy blue and sky blue, but exclude entries that solely have the target term blue.


Taxonomy taxonomy = stack.taxonomy().below("taxonomies.appliances", "led");
taxonomy.find(new TaxonomyCallback() {
            @Override
            public void onResponse(JSONObject response, Error error) {
                if (error!=null){
                    System.out.println("response :"+response);
                }
            }
        });
```

Enter the UID of the taxonomy

Enter the UID of the term

## equalAbove

The equalAbove method retrieves all entries for a specific taxonomy that match a specific term and all its ancestor terms, requiring only the target term and a specified level.

**Note**: If you don't specify the level, the default behavior is to retrieve terms up to level 10.

```
Example: If you want to obtain all entries that include the term LED and its parent term TV.
Taxonomy taxonomy = stack.taxonomy().equalAbove("taxonomies.appliances", "led");
taxonomy.find(new TaxonomyCallback() {
            @Override
            public void onResponse(JSONObject response, Error error) {
                if (error!=null){
                    System.out.println("response :"+response);
                }
            }
        });
```

Enter the UID of the taxonomy

Enter the UID of the term

## above

The above method retrieves all entries for a specific taxonomy that match only the parent term(s) of a specified target term, excluding the target term itself and a specified level.

**Note**: If you don't specify the level, the default behavior is to retrieve terms up to level 10.

```
Example: If you wish to match entries with the term tv but exclude the target term led.
Taxonomy taxonomy = stack.taxonomy().above("taxonomies.appliances", "led");
taxonomy.find(new TaxonomyCallback() {
            @Override
            public void onResponse(JSONObject response, Error error) {
                if (error!=null){
                    System.out.println("response :"+response);
                }
            }
        });
```

Enter the UID of the taxonomy

Enter the UID of the term

## find

The find method is used to get the API response.

```
Example:
taxonomy.find(new TaxonomyCallback() {
            @Override
            public void onResponse(JSONObject response, Error error) {
                if (error!=null){
                    System.out.println("response :"+response);
                }
            }
        });
```

The callback class that contains the API response

## Taxonomy | Java Delivery SDK | Contentstack

Taxonomy lets you categorize stack content in the Java Delivery SDK, enabling easy navigation and retrieval through hierarchical classification.