Class Taxonomy


  • public class Taxonomy
    extends Object
    Since:
    v1.13.0
    Author:
    Shailesh Mishra
    Taxonomy : Taxonomy, currently in the Early Access Phase simplifies the process of organizing content in your system, making it effortless to find and retrieve information. To implement the taxonomy use below code
         
         Stack stack = Contentstack.stack("API_KEY", "DELIVERY_TOKEN", "ENVIRONMENT");
         Taxonomy taxonomy = stack.taxonomy()
         
     
    See Also:
    • Method Detail

      • in

        public Taxonomy in​(String taxonomy,
                           List<String> listOfItems)
        Get all entries for a specific taxonomy that satisfy the given conditions provided in the '$in' query. Your query should be as follows:

         {"taxonomies.taxonomy_uid" : { "$in" : ["term_uid1" , "term_uid2" ] }}
         

        Example: If you want to retrieve entries with the color taxonomy applied and linked to the term red and/or yellow.

         {"taxonomies.color" : { "$in" : ["red" , "yellow" ] }}
         
        Parameters:
        taxonomy - the key of the taxonomy to query
        listOfItems - the list of taxonomy fields
        Returns:
        an instance of the Taxonomy with the specified conditions added to the query
      • or

        public Taxonomy or​(@NotNull
                           @NotNull List<org.json.JSONObject> listOfItems)
        OR Operator :

        Get all entries for a specific taxonomy that satisfy at least one of the given conditions provided in the “$or” query.

        Your query should be as follows:

        
         { $or: [
         { "taxonomies.taxonomy_uid_1" : "term_uid1" },
         { "taxonomies.taxonomy_uid_2" : "term_uid2" }
         ]}
        
         
        Example: If you want to retrieve entries with either the color or size taxonomy applied and linked to the terms yellow and small, respectively.
        
         { $or: [
         { "taxonomies.color" : "yellow" },
         { "taxonomies.size" : "small" }
         ]}
        
         
        Parameters:
        listOfItems - the list of items
        Returns:
        instance Taxonomy
      • and

        public Taxonomy and​(@NotNull
                            @NotNull List<org.json.JSONObject> listOfItems)
        AND Operator :

        Get all entries for a specific taxonomy that satisfy all the conditions provided in the “$and” query.

        Your query should be as follows:

         {
         $and: [
         { "taxonomies.taxonomy_uid_1" : "term_uid1" },
         { "taxonomies.taxonomy_uid_2" : "term_uid2" }
         ]
         }
         
        Example: If you want to retrieve entries with the color and computers taxonomies applied and linked to the terms red and laptop, respectively.
         {
         $and: [
         { "taxonomies.color" : "red" },
         { "taxonomies.computers" : "laptop" }
         ]
         }
         
        Parameters:
        listOfItems - the list of items to that you want to include in the query string
        Returns:
        instance of the Taxonomy
      • exists

        public Taxonomy exists​(@NotNull
                               @NotNull String taxonomy,
                               @NotNull
                               @NotNull Boolean value)
        Exists Operator :

        Get all entries for a specific taxonomy that if the value of the field, mentioned in the condition, exists.

        Your query should be as follows:

         {"taxonomies.taxonomy_uid" : { "$exists": true }}
         
        Example: If you want to retrieve entries with the color taxonomy applied.
         {"taxonomies.color" : { "$exists": true }}
         
        Parameters:
        taxonomy - the taxonomy
        value - the value of the field
        Returns:
        instance of Taxonomy
      • equalAndBelow

        public Taxonomy equalAndBelow​(@NotNull
                                      @NotNull String taxonomy,
                                      @NotNull
                                      @NotNull String termsUid)
        Equal and Below Operator :

        Get 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.

        {"taxonomies.taxonomy_uid" : { "$eq_below": "term_uid", "level" : 2}}
        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.
        {"taxonomies.color" : { "$eq_below": "blue" }}
        Parameters:
        taxonomy - the taxonomy
        termsUid - the term uid
        Returns:
        instance of Taxonomy
      • equalAndBelowWithLevel

        public Taxonomy equalAndBelowWithLevel​(@NotNull
                                               @NotNull String taxonomy,
                                               @NotNull
                                               @NotNull String termsUid,
                                               @NotNull
                                               @org.jetbrains.annotations.NotNull int level)
        Note: If you don't specify the level, the default behavior is to retrieve terms up to level 10.
        Parameters:
        taxonomy - the taxonomy
        termsUid - the terms
        level - the level to retrieve terms up to mentioned level
        Returns:
        instance of Taxonomy
      • below

        public Taxonomy below​(@NotNull
                              @NotNull String taxonomy,
                              @NotNull
                              @NotNull String termsUid)
        Below Operator

        Get 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.

        {"taxonomies.taxonomy_uid" : { "$below": "term_uid", "level" : 2}}
        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.
        {"taxonomies.color" : { "$below": "blue" }}
        Parameters:
        taxonomy - the taxonomy
        termsUid - the terms uid
        Returns:
        instance of Taxonomy
      • equalAbove

        public Taxonomy equalAbove​(@NotNull
                                   @NotNull String taxonomy,
                                   @NotNull
                                   @NotNull String termUid)
        Equal and Above Operator :

        Get 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.

        {"taxonomies.taxonomy_uid": { "$eq_above": "term_uid", "level": 2 }}

        Example: If you want to obtain all entries that include the term led and its parent term tv.

        {"taxonomies.appliances": { "$eq_above": "led"}}
        Parameters:
        taxonomy - the taxonomy
        termUid - the term uid
        Returns:
        instance of Taxonomy
      • above

        public Taxonomy above​(@NotNull
                              @NotNull String taxonomy,
                              @NotNull
                              @NotNull String termUid)
        Above Operator :

        Get all entries for a specific taxonomy that match only the parent term(s) of a specified target term, excluding the target term itself. You can also specify a specific level.

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

        { "taxonomies.taxonomy_uid": { "$above": "term_uid", "level": 2 }}

        Example: If you wish to match entries with the term tv but exclude the target term led.

        {"taxonomies.appliances": { "$above": "led" }}
        Parameters:
        taxonomy - the taxonomy
        termUid - the term uid
        Returns:
        instance of Taxonomy
      • find

        public void find​(TaxonomyCallback callback)
        Find.
        Parameters:
        callback - the callback