# What's wrong with this query?

**URL:** <https://discuss.elastic.co/t/whats-wrong-with-this-query/8376>\
**Category:** Elasticsearch\
**Created:** [July 10, 2012, 10:50am UTC](https://discuss.elastic.co/t/whats-wrong-with-this-query/8376 "2012-07-10T10:50:12Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Baishampayan\_Ghose](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/baishampayan_ghose/32/2815_2.png) [@Baishampayan\_Ghose](https://discuss.elastic.co/u/Baishampayan_Ghose)\
**Post date:** [July 10, 2012, 10:50am UTC](https://discuss.elastic.co/t/whats-wrong-with-this-query/8376/1 "2012-07-10T10:50:12Z")

</div>

Hi,

I am trying to query my index with a couple of filters like below but  
I am getting a QueryParsingException.

My query looks like this -

> <https://gist.github.com/ghoseb/3082632>

Can anyone tell me where I am doing it wrong?

I am just using a HTTP client at the moment.

Thanks in advance.

Regards,  
BG

--  
Baishampayan Ghose  
b.ghose at [gmail.com](http://gmail.com)

---

<div class="post-metadata">

**Author:** ![Baishampayan\_Ghose](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/baishampayan_ghose/32/2815_2.png) [@Baishampayan\_Ghose](https://discuss.elastic.co/u/Baishampayan_Ghose)\
**Post date:** [July 10, 2012, 11:55am UTC](https://discuss.elastic.co/t/whats-wrong-with-this-query/8376/2 "2012-07-10T11:55:40Z")

</div>

FWIW, I converted the original query document to a bool filter with  
must & should instead and it worked fine.

Does that mean and & or filters can't be combined together?

Regards,  
BG

On Tue, Jul 10, 2012 at 4:20 PM, Baishampayan Ghose [b.ghose@gmail.com](mailto:b.ghose@gmail.com) wrote:

> Hi,
> 
> I am trying to query my index with a couple of filters like below but  
> I am getting a QueryParsingException.
> 
> My query looks like this -
> 
> [Sample Query · GitHub](https://gist.github.com/3082632)
> 
> Can anyone tell me where I am doing it wrong?
> 
> I am just using a HTTP client at the moment.
> 
> Thanks in advance.
> 
> Regards,  
> BG
> 
> --  
> Baishampayan Ghose  
> b.ghose at [gmail.com](http://gmail.com)

--  
Baishampayan Ghose  
b.ghose at [gmail.com](http://gmail.com)

---

<div class="post-metadata">

**Author:** ![Igor\_Motov](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/igor_motov/32/45193_2.png) [@Igor\_Motov](https://discuss.elastic.co/u/Igor_Motov)\
**Post date:** [July 10, 2012, 2:19pm UTC](https://discuss.elastic.co/t/whats-wrong-with-this-query/8376/3 "2012-07-10T14:19:19Z")

</div>

They can be combined like this:

```
    "and": [{
      "or": [{
        "term": {
          "publish_id": "1"
        }
      }, {
        "term": {
          "publish_id": "10"
        }
      }]
    }, {
      "term": {
        "assignee": "unassigned"
      }
    }, {
      "term": {
        "priority": 1
      }
    }, {
      "term": {
        "tags": "foo"
      }
    }]

```

On Tuesday, July 10, 2012 7:55:40 AM UTC-4, Baishampayan Ghose wrote:

> FWIW, I converted the original query document to a bool filter with  
> must & should instead and it worked fine.
> 
> Does that mean and & or filters can't be combined together?
> 
> Regards,  
> BG
> 
> On Tue, Jul 10, 2012 at 4:20 PM, Baishampayan Ghose [b.ghose@gmail.com](mailto:b.ghose@gmail.com)  
> wrote:
> 
> > Hi,
> > 
> > I am trying to query my index with a couple of filters like below but  
> > I am getting a QueryParsingException.
> > 
> > My query looks like this -
> > 
> > [Sample Query · GitHub](https://gist.github.com/3082632)
> > 
> > Can anyone tell me where I am doing it wrong?
> > 
> > I am just using a HTTP client at the moment.
> > 
> > Thanks in advance.
> > 
> > Regards,  
> > BG
> > 
> > --  
> > Baishampayan Ghose  
> > b.ghose at [gmail.com](http://gmail.com)
> 
> --  
> Baishampayan Ghose  
> b.ghose at [gmail.com](http://gmail.com)

---

<div class="post-metadata">

**Author:** ![Baishampayan\_Ghose](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/baishampayan_ghose/32/2815_2.png) [@Baishampayan\_Ghose](https://discuss.elastic.co/u/Baishampayan_Ghose)\
**Post date:** [July 11, 2012, 4:52am UTC](https://discuss.elastic.co/t/whats-wrong-with-this-query/8376/4 "2012-07-11T04:52:47Z")

</div>

Thanks, Igor!

Regards,  
BG

On Tue, Jul 10, 2012 at 7:49 PM, Igor Motov [imotov@gmail.com](mailto:imotov@gmail.com) wrote:

> They can be combined like this:
> 
> ```
> "and": [{
> "or": [{
> "term": {
> "publish_id": "1"
> }
> }, {
> "term": {
> "publish_id": "10"
> }
> }]
> }, {
> "term": {
> "assignee": "unassigned"
> }
> }, {
> "term": {
> "priority": 1
> }
> }, {
> "term": {
> "tags": "foo"
> }
> }]
> 
> ```
> 
> On Tuesday, July 10, 2012 7:55:40 AM UTC-4, Baishampayan Ghose wrote:
> 
> > FWIW, I converted the original query document to a bool filter with  
> > must & should instead and it worked fine.
> > 
> > Does that mean and & or filters can't be combined together?
> > 
> > Regards,  
> > BG
> > 
> > On Tue, Jul 10, 2012 at 4:20 PM, Baishampayan Ghose [b.ghose@gmail.com](mailto:b.ghose@gmail.com)  
> > wrote:
> > 
> > > Hi,
> > > 
> > > I am trying to query my index with a couple of filters like below but  
> > > I am getting a QueryParsingException.
> > > 
> > > My query looks like this -
> > > 
> > > [Sample Query · GitHub](https://gist.github.com/3082632)
> > > 
> > > Can anyone tell me where I am doing it wrong?
> > > 
> > > I am just using a HTTP client at the moment.
> > > 
> > > Thanks in advance.
> > > 
> > > Regards,  
> > > BG
> > > 
> > > --  
> > > Baishampayan Ghose  
> > > b.ghose at [gmail.com](http://gmail.com)
> > 
> > --  
> > Baishampayan Ghose  
> > b.ghose at [gmail.com](http://gmail.com)

--  
Baishampayan Ghose  
b.ghose at [gmail.com](http://gmail.com)

---

<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, 3:20am UTC](https://discuss.elastic.co/t/whats-wrong-with-this-query/8376/5 "2017-07-06T03:20:39Z")

</div>


