# Getting 400 error when the items in the facet are unselected

**URL:** <https://discuss.elastic.co/t/getting-400-error-when-the-items-in-the-facet-are-unselected/292492>\
**Category:** Elastic Search\
**Tags:** elastic-app-search\
**Created:** [December 20, 2021, 4:38pm UTC](https://discuss.elastic.co/t/getting-400-error-when-the-items-in-the-facet-are-unselected/292492 "2021-12-20T16:38:44Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mecadamia.nut](https://avatars.discourse-cdn.com/v4/letter/m/e79b87/32.png) [@Mecadamia.nut](https://discuss.elastic.co/u/Mecadamia.nut)\
**Post date:** [December 20, 2021, 4:38pm UTC](https://discuss.elastic.co/t/getting-400-error-when-the-items-in-the-facet-are-unselected/292492/1 "2021-12-20T16:38:44Z")

</div>

Hi  
i have 4 to 5 facets in my app. when the user selects items across facets and then deselect items in another facet. I'm getting 400 error. Any idea of what is going wrong here.

An unexpected error occurred: [400] Facets cannot be empty or null

Below is the payload

```auto
{"query":"","facets":{},"filters":{"all":[{"any":[{"regioncountrylist":"United States"}]},{"any":[{"language":"English"}]},{"any":[]}]},"search_fields":{"title":{},"equipmentlist":{},"business_line":{},"reagentlist":{},"id":{},"pdfcontent":{},"productslist":{}},"result_fields":{"name":{"raw":{}},"title":{"raw":{}},"description":{"raw":{}},"revision":{"raw":{}},"equipmentlist":{"raw":{}},"tsc_priority":{"raw":{}},"filename":{"raw":{}},"createdate":{"raw":{}},"potentialhealth":{"raw":{}},"solution":{"raw":{}},"language":{"raw":{}},"datasize":{"raw":{}},"filetype":{"raw":{}},"document_classification":{"raw":{}},"document_classification_subcategory":{"raw":{}},"referencelist":{"raw":{}},"legacy_identifier":{"raw":{}},"fe_priority":{"raw":{}},"expirationdate":{"raw":{}},"publisheddate":{"raw":{}},"productslist":{"raw":{}},"modifydate":{"raw":{}},"usage_type":{"raw":{}},"lot":{"raw":{}},"parentid":{"raw":{}},"parenttype":{"raw":{}}},"page":{"size":0,"current":1},"analytics":{"tags":["Facet-Only"]}}

```

---

<div class="post-metadata">

**Author:** ![Mark\_Hoy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mark_hoy/32/99384_2.png) [@Mark\_Hoy](https://discuss.elastic.co/u/Mark_Hoy)\
**Post date:** [December 21, 2021, 2:03pm UTC](https://discuss.elastic.co/t/getting-400-error-when-the-items-in-the-facet-are-unselected/292492/2 "2021-12-21T14:03:03Z")

</div>

Hi Chandra -

Can you detail out a bit more about your application? What is the search front end you are using? What version of Enterprise Search?

---

<div class="post-metadata">

**Author:** ![Mecadamia.nut](https://avatars.discourse-cdn.com/v4/letter/m/e79b87/32.png) [@Mecadamia.nut](https://discuss.elastic.co/u/Mecadamia.nut)\
**Post date:** [December 21, 2021, 8:30pm UTC](https://discuss.elastic.co/t/getting-400-error-when-the-items-in-the-facet-are-unselected/292492/3 "2021-12-21T20:30:15Z")

</div>

I'm using AppSearch 7.15.1 i'm using react app. After further digging down, i see the call that is failing is for 'Analytics'. I see "analytics: {tags: ["Facet-Only"]}" payload being sent. is there a way to stop the calls for analytics. if i'm selecting 4 filters. it makes up 5 calls out of which 4 calls are for these analytics only.

---

<div class="post-metadata">

**Author:** ![Mecadamia.nut](https://avatars.discourse-cdn.com/v4/letter/m/e79b87/32.png) [@Mecadamia.nut](https://discuss.elastic.co/u/Mecadamia.nut)\
**Post date:** [December 28, 2021, 2:03pm UTC](https://discuss.elastic.co/t/getting-400-error-when-the-items-in-the-facet-are-unselected/292492/4 "2021-12-28T14:03:17Z")

</div>

Looks like the conditionalFacets is causing this issue. once i removed the conditional facets code, i don't get the error. i had to check the length of the filters to get around the conditionalfacets requirements

---

<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:** [January 25, 2022, 2:03pm UTC](https://discuss.elastic.co/t/getting-400-error-when-the-items-in-the-facet-are-unselected/292492/5 "2022-01-25T14:03:33Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
