---
title: Categories
slug: indexing-apis/categories
docTags: 
createdAt: 2023-10-12T15:16:54.208Z
---

If you are using category merchandising and want to associate products with the categories, then first index a category item and then index products by creating their relationship with the category. Products can be mapped to multiple categories. Following is an example of how to do it.

:::BlockQuote
\[
&#x20;   \{
&#x20;       "id": "men-shirts",
&#x20;       "type": "KLEVU\_CATEGORY",
&#x20;       "attributes": \{
&#x20;           "name": \{
&#x20;               "default": "Shirts"
&#x20;           },
&#x20;           "url": "https\://test.myshopify.com/collections/men-shirts",
&#x20;           "categoryPath": "Mens;Shirts"
&#x20;       }
&#x20;   },
&#x20;   \{
&#x20;       "id": "1",
&#x20;       "type": "KLEVU\_PRODUCT",
&#x20;       "relations": \{
&#x20;           "categories": \{
&#x20;               "values": \[
&#x20;                   "men-shirts"
&#x20;               ]
&#x20;           }
&#x20;       },
&#x20;       "attributes": \{
&#x20;           "name": \{
&#x20;               "default": "Shirt"
&#x20;           },
&#x20;           "image": \{
&#x20;               "default": \{
&#x20;                   "url": "https\://4.imimg.com/data4/AO/DA/MY-24693421/comfortable-office-chair.jpg"
&#x20;               }
&#x20;           },
&#x20;           "url": "https\://test.myshopify.com/products/black-shirt",
&#x20;           "shortDescription": \{
&#x20;               "default": "This is a black shirt available in different sizes."
&#x20;           }
&#x20;       }
&#x20;   },
&#x20;   \{
&#x20;       "id": "2",
&#x20;       "type": "KLEVU\_PRODUCT",
&#x20;       "relations": \{
&#x20;           "parentProduct": \{
&#x20;               "values": \[
&#x20;                   "1"
&#x20;               ]
&#x20;           },
&#x20;           "categories": \{
&#x20;               "values": \[
&#x20;                   "men-shirts"
&#x20;               ]
&#x20;           }
&#x20;       },
&#x20;       "attributes": \{
&#x20;           "name": \{
&#x20;               "default": "Shirt"
&#x20;           },
&#x20;           "image": \{
&#x20;               "default": \{
&#x20;                   "url": "https\://4.imimg.com/data4/AO/DA/MY-24693421/comfortable-office-chair.jpg"
&#x20;               }
&#x20;           },
&#x20;           "price": \{
&#x20;               "GBP": \{
&#x20;                   "salePrice": 80
&#x20;               }
&#x20;           },
&#x20;           "url": "https\://test.myshopify.com/products/black-shirt-s",
&#x20;           "shortDescription": \{
&#x20;               "default": "Black Shirt"
&#x20;           },
&#x20;           "size": "s"
&#x20;       }
&#x20;   },
&#x20;   \{
&#x20;       "id": "3",
&#x20;       "type": "KLEVU\_PRODUCT",
&#x20;       "relations": \{
&#x20;           "parentProduct": \{
&#x20;               "values": \[
&#x20;                   "1"
&#x20;               ]
&#x20;           },
&#x20;           "categories": \{
&#x20;               "values": \[
&#x20;                   "men-shirts"
&#x20;               ]
&#x20;           }
&#x20;       },
&#x20;       "attributes": \{
&#x20;           "name": \{
&#x20;               "default": "Shirt"
&#x20;           },
&#x20;           "image": \{
&#x20;               "default": \{
&#x20;                   "url": "https\://4.imimg.com/data4/AO/DA/MY-24693421/comfortable-office-chair.jpg"
&#x20;               }
&#x20;           },
&#x20;           "price": \{
&#x20;               "GBP": \{
&#x20;                   "salePrice": 100
&#x20;               }
&#x20;           },
&#x20;           "url": "https\://test.myshopify.com/products/black-shirt-m",
&#x20;           "shortDescription": \{
&#x20;               "default": "Black Shirt"
&#x20;           },
&#x20;           "size": "m"
&#x20;       }
&#x20;   }
]
:::

:::hint{type="info"}
- For a complex product, ensure mapping all variants to the category.
- Items of different types like categories, products, etc can be part of the same request payload.
- Order should be maintained when objects are being related i.e. If you are mapping a product to a category, then the category should be created before the product.
:::

