# Error: \[400\] Filters contains an invalid set of keys for object inside of field: filters root; can only have clauses or a single field name

**URL:** <https://discuss.elastic.co/t/error-400-filters-contains-an-invalid-set-of-keys-for-object-inside-of-field-filters-root-can-only-have-clauses-or-a-single-field-name/221124>\
**Category:** Elastic Search\
**Tags:** elastic-app-search\
**Created:** [February 27, 2020, 1:05am UTC](https://discuss.elastic.co/t/error-400-filters-contains-an-invalid-set-of-keys-for-object-inside-of-field-filters-root-can-only-have-clauses-or-a-single-field-name/221124 "2020-02-27T01:05:58Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Hayden-NTW](https://avatars.discourse-cdn.com/v4/letter/h/c89c15/32.png) [@Hayden-NTW](https://discuss.elastic.co/u/Hayden-NTW)\
**Post date:** [February 27, 2020, 1:05am UTC](https://discuss.elastic.co/t/error-400-filters-contains-an-invalid-set-of-keys-for-object-inside-of-field-filters-root-can-only-have-clauses-or-a-single-field-name/221124/1 "2020-02-27T01:05:58Z")

</div>

I'm trying to get filtered result from elastic/app-search.

Below is facets data from first search.

```
<h3>Brand</h3>
<input type="checkbox" name="brand1" value="brand1">
<input type="checkbox" name="brand2" value="brand2">

<h3>Price</h3>
<input type="checkbox" name="price1" value="price1">
<input type="checkbox" name="price2" value="price2">

```

When user click any checkbox, the value is contained to product\_options's filter.  
It's working if filter has one condition like this:

```
product_options {
    result_fields: {...},
    facets: {...},
    page: {...},
    sort: {...},
    filteres: {
        brand: ["brand1"] 
    }
}

```

And it still working when there's 2 or more brands. like this:

```
product_options {
    result_fields: {...},
    facets: {...},
    page: {...},
    sort: {...},
    filteres: {
        brand: ["brand1", "brand2"...] 
    }
}

```

but, when the filters object has 2 or more conditions in its root, the error occurred like this:

> Error: [400] Filters contains an invalid set of keys for object inside of field: filters root; can only have clauses or a single field name

**If I want to use multi condition like below:**

```
filters: {
    brand: ["brand1"],
    price: ["price1"]
}

```

**What should I do?**

Thank you for reading and helping!

---

<div class="post-metadata">

**Author:** ![JasonStoltz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jasonstoltz/32/49893_2.png) [@JasonStoltz](https://discuss.elastic.co/u/JasonStoltz)\
**Post date:** [February 27, 2020, 12:26pm UTC](https://discuss.elastic.co/t/error-400-filters-contains-an-invalid-set-of-keys-for-object-inside-of-field-filters-root-can-only-have-clauses-or-a-single-field-name/221124/2 "2020-02-27T12:26:35Z")

</div>

When applying one filter you can use the shorthand syntax as you have above.

When applying multiple filters, you need to use the full filter syntax documented here: [https://swiftype.com/documentation/app-search/api/search/filters#combining-filters](https://swiftype.com/documentation/app-search/api/search/filters#combining-filters)

```auto
"filters": {
  "all": [
    { "brand": ["brand1"] },
    { "price": ["price1"] }
  ]
]}

```

---

<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:** [March 26, 2020, 6:36pm UTC](https://discuss.elastic.co/t/error-400-filters-contains-an-invalid-set-of-keys-for-object-inside-of-field-filters-root-can-only-have-clauses-or-a-single-field-name/221124/4 "2020-03-26T18:36:35Z")

</div>

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