# How to achieve hierarchical facets without using swift dependencies

**URL:** https://discuss.elastic.co/t/how-to-achieve-hierarchical-facets-without-using-swift-dependencies/286413
**Category:** Elastic Search
**Created:** [October 11, 2021, 8:38pm UTC](https://discuss.elastic.co/t/how-to-achieve-hierarchical-facets-without-using-swift-dependencies/286413 "2021-10-11T20:38:46Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![pradeepjanga](https://avatars.discourse-cdn.com/v4/letter/p/9e8a1a/32.png) [@pradeepjanga](https://discuss.elastic.co/u/pradeepjanga)
#### Post date: [October 11, 2021, 8:38pm UTC](https://discuss.elastic.co/t/how-to-achieve-hierarchical-facets-without-using-swift-dependencies/286413/1 "2021-10-11T20:38:46Z")

</div>

am following below example to develop with React App search UI.

> <https://github.com/elastic/search-ui/issues/285>
>
> Example in App Search Documentation:
> https://swiftype.com/documentation/app-sea…rch/guides/hierarchical-facets
> 
> Live example using App Search:
> https://github.com/swiftype/swiftype-app-search-hierarchical-facets-example

I want to call search Api when user click on 1st level category to get the 2nd level categories but the Api connector doesn't have a method to call search. Like below code:

```auto
var client = SwiftypeAppSearch.createClient({

  hostIdentifier: "host-n16af4",

  searchKey: "search-foueoyusuprj187kv7hyfof9",

  engineName: "hierarchichal-facets"

});

```

```auto
getCategory1Facets = async () => {

    const results = await client.search(this.state.searchTerm, {

      page: {

        size: 0

      },

      facets: {

        category1: [

          {

            type: "value"

          }

        ]

      }

    });

    return results.info.facets;

  };

```

But i dont have search method on the connector am using. below is sample code.  
How to achieve that without swift connector ?

```auto
const connector = new AppSearchAPIConnector({
  searchKey: "search-371auk61r2bwqtdzocdgutmg",
  engineName: "search-ui-examples",
  hostIdentifier: "host-2376rb",
  beforeSearchCall: (existingSearchOptions, next) =>
    next({
      ...existingSearchOptions,
      group: { field: "title" }
    })
});

```

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)
#### Post date: [November 4, 2022, 8:32am UTC](https://discuss.elastic.co/t/how-to-achieve-hierarchical-facets-without-using-swift-dependencies/286413/2 "2022-11-04T08:32:39Z")

</div>


