# Getting error when applying AND & OR filter

**URL:** <https://discuss.elastic.co/t/getting-error-when-applying-and-or-filter/13029>\
**Category:** Elasticsearch\
**Created:** [August 1, 2013, 12:58pm UTC](https://discuss.elastic.co/t/getting-error-when-applying-and-or-filter/13029 "2013-08-01T12:58:38Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Johnson\_Cheng](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/johnson_cheng/32/2194_2.png) [@Johnson\_Cheng](https://discuss.elastic.co/u/Johnson_Cheng)\
**Post date:** [August 1, 2013, 12:58pm UTC](https://discuss.elastic.co/t/getting-error-when-applying-and-or-filter/13029/1 "2013-08-01T12:58:38Z")

</div>

I've spent quite sometime to google for the solution. I want to apply AND &  
OR filter together for my query but I'm getting error message returned

"\* filter malformed, must start with start\_object\*"

My filter query as below:

filter: {  
"and": [{"not":  
{"terms":

{"article\_id":["72A3F3E1-82AF-46E3-9DCC579ED6D36735"]}  
}  
},  
{"terms":  
{"page\_type":["article"]}  
},  
{"or":

{"terms":{"document\_types":["F04CA6D9-27CA-45FD-985371B7DD283452","5D95860A-6219-4ED0-A085DE269D562300"]}  
}  
}]  
}

Can anyone help please?

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![radu\_gheorghe](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/radu_gheorghe/32/556_2.png) [@radu\_gheorghe](https://discuss.elastic.co/u/radu_gheorghe)\
**Post date:** [August 1, 2013, 3:49pm UTC](https://discuss.elastic.co/t/getting-error-when-applying-and-or-filter/13029/2 "2013-08-01T15:49:30Z")

</div>

Hello,

I think the problem is that your "or" filter expects an array of filters,  
and not just one filter.

If I'm not guessing right, can you provide a curl  
recreation[http://www.elasticsearch.org/help/](http://www.elasticsearch.org/help/)of the problem? I think  
that will make things easier to diagnose.

## Best regards, Radu

[http://sematext.com/](http://sematext.com/) -- Elasticsearch -- Solr -- Lucene

On Thu, Aug 1, 2013 at 3:58 PM, Johnson Cheng [johnson.cheng@pixl8.co.uk](mailto:johnson.cheng@pixl8.co.uk)wrote:

> I've spent quite sometime to google for the solution. I want to apply AND  
> & OR filter together for my query but I'm getting error message returned
> 
> "\* filter malformed, must start with start\_object\*"
> 
> My filter query as below:
> 
> filter: {  
> "and": [{"not":  
> {"terms":
> 
> {"article\_id":["72A3F3E1-82AF-46E3-9DCC579ED6D36735"]}  
> }  
> },  
> {"terms":  
> {"page\_type":["article"]}  
> },  
> {"or":
> 
> {"terms":{"document\_types":["F04CA6D9-27CA-45FD-985371B7DD283452","5D95860A-6219-4ED0-A085DE269D562300"]}  
> }  
> }]  
> }
> 
> Can anyone help please?
> 
> --  
> You received this message because you are subscribed to the Google Groups  
> "elasticsearch" group.  
> To unsubscribe from this group and stop receiving emails from it, send an  
> email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<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:** [July 6, 2017, 2:23am UTC](https://discuss.elastic.co/t/getting-error-when-applying-and-or-filter/13029/3 "2017-07-06T02:23:21Z")

</div>


