# Get non-selected facet values

**URL:** <https://community.swiftype.com/t/get-non-selected-facet-values/662>\
**Category:** General\
**Created:** [April 11, 2018, 7:39am UTC](https://community.swiftype.com/t/get-non-selected-facet-values/662 "2018-04-11T07:39:54Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![stefan](https://sea1.discourse-cdn.com/flex019/user_avatar/community.swiftype.com/stefan/32/139_2.png) [@stefan](https://community.swiftype.com/u/stefan)\
**Post date:** [April 11, 2018, 7:39am UTC](https://community.swiftype.com/t/get-non-selected-facet-values/662/1 "2018-04-11T07:39:55Z")

</div>

We tried to create facets with multiple options:

```
=== Document Type ===
[] Word (42)
[x] PDF (96)
[] Excel(11)
[] HTML (63)

```

Unfortunately if you select one facet, you do not get the counts for other facet values. Is it possible to get values and counts for not selected facets?

---

<div class="post-metadata">

**Author:** ![chad.johnson](https://avatars.discourse-cdn.com/v4/letter/c/848f3c/32.png) [@chad.johnson](https://community.swiftype.com/u/chad.johnson)\
**Post date:** [April 17, 2018, 9:30pm UTC](https://community.swiftype.com/t/get-non-selected-facet-values/662/2 "2018-04-17T21:30:40Z")

</div>

The API will not return the other values once you apply one of them as a filter, but you can cache them yourself in the UI. After the results reload, continue to display the original list of filters, with some of them selected and some not, accordingly. Once the user changes the main query, reset the cached list and start over.

---

<div class="post-metadata">

**Author:** ![stefan](https://sea1.discourse-cdn.com/flex019/user_avatar/community.swiftype.com/stefan/32/139_2.png) [@stefan](https://community.swiftype.com/u/stefan)\
**Post date:** [April 18, 2018, 4:25am UTC](https://community.swiftype.com/t/get-non-selected-facet-values/662/3 "2018-04-18T04:25:15Z")

</div>

I’m curious; this is a core feature of elasticsearch (facets + aggregations). Why is the API limited to not use this features?

---

<div class="post-metadata">

**Author:** ![chad.johnson](https://avatars.discourse-cdn.com/v4/letter/c/848f3c/32.png) [@chad.johnson](https://community.swiftype.com/u/chad.johnson)\
**Post date:** [April 18, 2018, 1:02pm UTC](https://community.swiftype.com/t/get-non-selected-facet-values/662/4 "2018-04-18T13:02:07Z")

</div>

Swiftype was originally built on an older version of Elastic. I believe there are efforts to upgrade it to a more current version but I have no specific information.

---

<div class="post-metadata">

**Author:** ![micah.herstand](https://avatars.discourse-cdn.com/v4/letter/m/e95f7d/32.png) [@micah.herstand](https://community.swiftype.com/u/micah.herstand)\
**Post date:** [September 11, 2018, 9:05pm UTC](https://community.swiftype.com/t/get-non-selected-facet-values/662/5 "2018-09-11T21:05:46Z")

</div>

I would also like to be able to get non-selected facet values.

I am loading search results based on the URL, so users can bookmark or share the URL and get results with all filters applied. The way this API is currently built, that would require me to run two API calls if their bookmarked URL is faceted. The first unfiltered one gets all the facet result counts, and the second gets the filtered results.

Unless I’m missing something?

---

<div class="post-metadata">

**Author:** ![jason.stoltzfus](https://sea1.discourse-cdn.com/flex019/user_avatar/community.swiftype.com/jason.stoltzfus/32/171_2.png) [@jason.stoltzfus](https://community.swiftype.com/u/jason.stoltzfus)\
**Post date:** [October 31, 2018, 3:16pm UTC](https://community.swiftype.com/t/get-non-selected-facet-values/662/6 "2018-10-31T15:16:00Z")

</div>

@stefan I’m curious, how would you accomplish this in Elasticsearch? If you apply a filter on a field and also a terms aggregation on the same field, I believe that would result in just the counts for the current result set. So going back to the original example, it would end up looking something like:

```
=== Document Type ===
[x] PDF (96)

```

@micah.herstand Are you using App Search or Site Search? There is a solution for this with App Search, called “Disjunctive Faceting”. It will run separate queries, as you describe @micah.herstand, to achieve this automatically. It leverages caching to reduce additional network traffic this causes.

It’s currently available in the 2.0 version of the JavaScript API client. [GitHub - swiftype/swiftype-app-search-javascript: Swiftype App Search Javascript Client](https://github.com/swiftype/swiftype-app-search-javascript)
