> ## Documentation Index
> Fetch the complete documentation index at: https://doc.lucidworks.com/llms.txt
> Use this file to discover all available pages before exploring further.

# facet:hierarchical

export const LwTemplate = ({title = "Key questions to get you started", icon = "sparkles", cta = "Powered by Agent Studio", linkHref = "https://lucidworks.com/demo/?utm_source=docs&utm_medium=referral&utm_campaign=docs_cta_ai"}) => {
  const [isLoaded, setIsLoaded] = useState(false);
  useEffect(() => {
    const timer = setTimeout(() => {
      setIsLoaded(true);
    }, 500);
    return () => clearTimeout(timer);
  }, []);
  return <div className="lw-template-container">
      <Card title={title} icon={icon}>
        {isLoaded && <span dangerouslySetInnerHTML={{
    __html: `<lw-template id="a029c1a9-28be-427e-b0e1-5d918920246a"></lw-template
            >`
  }} />}
        <Link href={linkHref} className="agent-studio-link text-left text-gray-600 gap-2 dark:text-gray-400 text-sm font-medium flex flex-row items-center hover:text-primary dark:hover:text-primary-light group-hover:text-primary group-hover:dark:text-primary-light">Powered by Lucidworks Agent Studio</Link>
      </Card>
    </div>;
};

[localhost link]: http://localhost:3000/docs/4/app-studio/reference/tags/lightning.directive.facetHierarchical

[mintlify link]: https://doc.lucidworks.com/docs/4/app-studio/reference/tags/lightning.directive.facetHierarchical

[old doc.lw link]: https://doc.lucidworks.com/app-studio/4.2/1094

<LwTemplate />

## Description

Hierarchical Facets for Solr.

In order to correctly display a taxonomy as a hierarchical facet you
need to configure the requisite Twigkit service to retrieve the data
structure \[configured in your Solr index]\[1].

First you need to create a service configuration:

```bash wrap  theme={"dark"}
 /conf
     /services
         /hierarchical
             /hierarchical.conf
```

The file 'hierarchical.conf' should be configured similar to the
following example:

```yml wrap  theme={"dark"}
name: twigkit.search.solr.service.facet.GreedySolrHierarchicalFacetService
platform: platforms.solr
parents-suffix: _parent
```

> **platform** This specifies the configured platform where the taxonomy has
> been indexed.

> **parents-suffix** The suffix, that if appended to the facet’s fieldname
> will designate the field containing parent node data. Will depend on how
> the taxonomy data has been indexed.

**Example:**

```xml wrap  theme={"dark"}
<search:platform var="platformHierarchical" conf="services.hierarchical"></search:platform>
<search:facet facet-name="location" show="6" show-more="6">
    <facet:hierarchical facet-name="location" platform="platformHierarchical" query="query"></facet:hierarchical>
</search:facet>
```

## Usage

as element:

```xml wrap  theme={"dark"}
<facet:hierarchical
       query="{string}"
       [facet-name="{string}"]
       [platform="{string}"]
       [count-number="{string}"]
       [select="{string}"]
       [max-characters="{Number}"]
       [expand-root="{boolean}"]>
</facet:hierarchical>
```

### Directive info

* This directive creates new scope.

#### Parameters

| Param                          | Type        | Details                                                                                                                                                                                                                                             |
| ------------------------------ | ----------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `query`                        | **string**  | The name of the query object.                                                                                                                                                                                                                       |
| `facet-name`  *(optional)*     | **string**  | Facet name to use from the response object                                                                                                                                                                                                          |
| `platform`  *(optional)*       | **string**  | The name of the platform to use.                                                                                                                                                                                                                    |
| `count-number`  *(optional)*   | **string**  | Specify how the number representing the count should be formatted. Optional values are `plain`, `formatted`, and `rounded`. Rounded uses a short format (2k for \~2000). Formatted is comma formatted (2,000,000 for 2000000). Default: `formatted` |
| `select`  *(optional)*         | **string**  | How to render each `FacetFilter`. `click`: User selects a filter by clicking the value; and `mutliselect`: Supports selecting multiple filters that get combined with an `OR`. Default: `click`                                                     |
| `max-characters`  *(optional)* | **Number**  | Limit display value to a certain number of characters, adding `…​` if `maxCharacters` is exceeded.                                                                                                                                                  |
| `expand-root`  *(optional)*    | **boolean** | If only one root filter exists, if this is set to true it will expand this filter showing the children. (Default:`false`).                                                                                                                          |

## Example

#### Source

```xml wrap  theme={"dark"}
<search:platform var="platform" conf="platforms.workflow.data.collection.google-directory"></search:platform>
<search:query var="query" parameters='q' results-per-page="1"></search:query>
<search:facet-list response="response" styling="facet-list facet-list-step facet-list-wrappedheader facet-list-wrappedheader-noborder">
    <search:facet facet-name="test1" title="First Pass Files" collapsible="true">
        <facet:hierarchical facet-name="test1" platform="platform" query="query"></facet:hierarchical>
    </search:facet>
</search:facet-list>
```

```js wrap  expandable  theme={"dark"}
angular.module('lightning')
.controller('ExampleController', ['$scope','$timeout','ResponseService', function($scope,$timeout,ResponseService) {
            $scope.response = {
                page: 2,
                query: {
                    rpp: 50
                },
                facets: {
                    test: {
                        filters: [
                            {

                                val: {
                                    dsp: 'Day 1',
                                    act: 'Day 1',

                                },
                                count: 100,

                            },
                            {

                                val: {
                                    dsp: 'Day 2',
                                    act: 'Day 2',
                                },
                                count: 200,
                            }

                        ]
                    },
                },
                results: []
            }
            ResponseService.setResponse('response', $scope.response);
        }]);
```
