--- title: Folding fields slug: '2718' canonical_url: https://docs.coveo.com/en/2718/ collection: javascript-search-framework source_format: adoc --- # Folding fields The [`FoldingForThread`](https://coveo.github.io/search-ui/classes/foldingforthread.html)/[`Folding`](https://coveo.github.io/search-ui/components/folding.html) components rely on three distinct [fields](https://docs.coveo.com/en/200/) in your [index](https://docs.coveo.com/en/204/). By default, those fields are: * `@foldingcollection` Identifies the folding group each [item](https://docs.coveo.com/en/210/) belongs to (for example, all items belonging to the `ABC` folding group should have `ABC` as their `@foldingcollection` field value). * `@foldingchild` Uniquely identifies each item. * `@foldingparent` Identifies the parent of each item (for example, all items whose parent has `123` as its `@foldingchild` value should have `123` as their `@foldingparent` value). > **Note** > > Any item whose `@foldingchild` and `@foldingparent` field values are identical is considered to have no parent. **Example** Assuming you're using the default folding fields, parent-child relationships could be represented as such in your index: * Sample one-level parent-child relationship: ** Original message @foldingcollection: "ABC" @foldingchild: "123" @foldingparent: "123" *** Reply 1 @foldingcollection: "ABC" @foldingchild: "124" @foldingparent: "123" *** Reply 2 @foldingcollection: "ABC" @foldingchild: "125" @foldingparent: "123" You should typically use the `FoldingForThread` component when dealing only with one-level relationships. * Sample multi-level parent-child relationship: ** Original message @foldingcollection: "ABC" @foldingchild: "123" @foldingparent: "123" *** Reply 1 @foldingcollection: "ABC" @foldingchild: "124" @foldingparent: "123" **** Attachment 1 @foldingcollection: "ABC" @foldingchild: "127" @foldingparent: "124" *** Reply 2 @foldingcollection: "ABC" @foldingchild: "125" @foldingparent: "123" You should typically use the `Folding` component when you may have to deal with multi-level relationships. If necessary, you can specify custom folding fields to use instead of the default ones with the following `FoldingForThread`/`Folding` configuration options: * [`field`](https://coveo.github.io/search-ui/components/folding.html#options.field) to override `@foldingcollection` * [`child`](https://coveo.github.io/search-ui/components/folding.html#options.child) to override `@foldingchild` * [`parent`](https://coveo.github.io/search-ui/components/folding.html#options.parent) to override `@foldingparent` > **Important** > > If you specify custom folding fields, remember that in the index, each folding field must: > > * Be of the [String type](https://docs.coveo.com/en/1833#field-type). > * Have the [**Displayable in Results** option](https://docs.coveo.com/en/1833#search-operator-and-displayable-in-results) enabled. > > Moreover, values in the `child` and `parent` fields may only contain up to 60 alphanumeric characters (for example, assuming you're using the default folding fields, `123abc` is a valid `@foldingchild`/`@foldingparent` value, whereas `123_abc` is not). > **Notes** > > * If you're familiar with the Coveo Search API, it's worth mentioning that: > ** The `field` option sets the [`filterField`](https://docs.coveo.com/en/13#operation/searchUsingPost-filterField) query parameter. > ** The `child` option sets the [`parentField`](https://docs.coveo.com/en/13#operation/searchUsingPost-parentField) (**not** `childField`) query parameter. > ** The `parent` option sets the [`childField`](https://docs.coveo.com/en/13#operation/searchUsingPost-childField) (**not** `parentField`) query parameter. > ** The [`range`](https://coveo.github.io/search-ui/components/folding.html#options.range) option sets the [`filterFieldRange`](https://docs.coveo.com/en/13#operation/searchUsingPost-filterFieldRange) query parameter. > * Before the May 2018 release of the JavaScript Search Framework (see [May 2018 release (v2.4094.8)](https://docs.coveo.com/en/410#may-2018-release-v240948)), the option to use for `child` was [`parent-field`](https://coveo.github.io/search-ui/components/folding.html#options.parentfield), and the option to use for `parent` was [`child-field`](https://coveo.github.io/search-ui/components/folding.html#options.childfield). > Those options are now deprecated.