# Disable Coord in Bool query with query DSL

**URL:** https://discuss.elastic.co/t/disable-coord-in-bool-query-with-query-dsl/3099
**Category:** Elasticsearch
**Created:** [July 14, 2010, 3:20pm UTC](https://discuss.elastic.co/t/disable-coord-in-bool-query-with-query-dsl/3099 "2010-07-14T15:20:21Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![Jacob\_Robertson\_2](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jacob_robertson_2/32/3332_2.png) [@Jacob\_Robertson\_2](https://discuss.elastic.co/u/Jacob_Robertson_2)
#### Post date: [July 14, 2010, 3:20pm UTC](https://discuss.elastic.co/t/disable-coord-in-bool-query-with-query-dsl/3099/1 "2010-07-14T15:20:21Z")

</div>

I am using a bool query to combine several dis\_max queries. I was  
getting some results in a rather unexpected order and went to check  
out the JSON returned by elasticsearch. Much to my surprise, on about  
half of the documents coming out of this bool query, the coord factor  
was not being applied. First of all assuming my query json is well-  
formed, this is rather inconsistent. Additionally is there a way with  
the query DSL to disable coord much like Lucene's BooleanQuery. The  
query I am sending to elasticsearch looks something like this

{  
"query":{  
"bool":{  
"should":[{  
"dis\_max":{  
"queries":[{  
"constant\_score":{  
"filter":{  
"query":{  
"prefix":{  
"school":"foo"  
}  
}  
},  
"boost":1.0  
}  
},{  
"constant\_score":{  
"filter":{  
"query":{  
"term":{  
"school":"foo"  
}  
}  
},  
"boost":1.4  
}  
},{  
"constant\_score":{  
"filter":{  
"query":{  
"prefix":{  
"username":"foo"  
}  
}  
},  
"boost":1.1  
}  
},{  
"constant\_score":{  
"filter":{  
"query":{  
"term":{  
"username":"foo"  
}  
}  
},  
"boost":1.5  
}  
},{  
"constant\_score":{  
"filter":{  
"query":{  
"prefix":{  
"lastname":"foo"  
}  
}  
},  
"boost":1.2000000000000002  
}  
},{  
"constant\_score":{  
"filter":{  
"query":{  
"term":{  
"lastname":"foo"  
}  
}  
},  
"boost":1.6  
}  
},{  
"constant\_score":{  
"filter":{  
"query":{  
"prefix":{  
"firstname":"foo"  
}  
}  
},  
"boost":1.3000000000000003  
}  
},{  
"constant\_score":{  
"filter":{  
"query":{  
"term":{  
"firstname":"foo"  
}  
}  
},  
"boost":1.7000000000000002  
}  
}]  
}  
},{  
"dis\_max":{  
"queries":[{  
"constant\_score":{  
"filter":{  
"query":{  
"prefix":{  
"school":"bar"  
}  
}  
},  
"boost":1.0  
}  
},{  
"constant\_score":{  
"filter":{  
"query":{  
"term":{  
"school":"bar"  
}  
}  
},  
"boost":1.4  
}  
},{  
"constant\_score":{  
"filter":{  
"query":{  
"prefix":{  
"username":"bar"  
}  
}  
},  
"boost":1.1  
}  
},{  
"constant\_score":{  
"filter":{  
"query":{  
"term":{  
"username":"bar"  
}  
}  
},  
"boost":1.5  
}  
},{  
"constant\_score":{  
"filter":{  
"query":{  
"prefix":{  
"lastname":"bar"  
}  
}  
},  
"boost":1.2000000000000002  
}  
},{  
"constant\_score":{  
"filter":{  
"query":{  
"term":{  
"lastname":"bar"  
}  
}  
},  
"boost":1.6  
}  
},{  
"constant\_score":{  
"filter":{  
"query":{  
"prefix":{  
"firstname":"bar"  
}  
}  
},  
"boost":1.3000000000000003  
}  
},{  
"constant\_score":{  
"filter":{  
"query":{  
"term":{  
"firstname":"bar"  
}  
}  
},  
"boost":1.7000000000000002  
}  
}]  
}  
}]  
}  
}  
}

---

<div class="post-metadata">

### Author: ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)
#### Post date: [July 14, 2010, 5:39pm UTC](https://discuss.elastic.co/t/disable-coord-in-bool-query-with-query-dsl/3099/2 "2010-07-14T17:39:33Z")

</div>

Where do you see coord being disabled? You can control it in elasticsearch  
for boolean queries, but, by default, it is true.

-shay.banon

On Wed, Jul 14, 2010 at 6:20 PM, Jacob Robertson \<  
[g.jacob.robertson@gmail.com](mailto:g.jacob.robertson@gmail.com)\> wrote:

> I am using a bool query to combine several dis\_max queries. I was  
> getting some results in a rather unexpected order and went to check  
> out the JSON returned by elasticsearch. Much to my surprise, on about  
> half of the documents coming out of this bool query, the coord factor  
> was not being applied. First of all assuming my query json is well-  
> formed, this is rather inconsistent. Additionally is there a way with  
> the query DSL to disable coord much like Lucene's BooleanQuery. The  
> query I am sending to elasticsearch looks something like this
> 
> {  
> "query":{  
> "bool":{  
> "should":[{  
> "dis\_max":{  
> "queries":[{  
> "constant\_score":{  
> "filter":{  
> "query":{  
> "prefix":{  
> "school":"foo"  
> }  
> }  
> },  
> "boost":1.0  
> }  
> },{  
> "constant\_score":{  
> "filter":{  
> "query":{  
> "term":{  
> "school":"foo"  
> }  
> }  
> },  
> "boost":1.4  
> }  
> },{  
> "constant\_score":{  
> "filter":{  
> "query":{  
> "prefix":{  
> "username":"foo"  
> }  
> }  
> },  
> "boost":1.1  
> }  
> },{  
> "constant\_score":{  
> "filter":{  
> "query":{  
> "term":{  
> "username":"foo"  
> }  
> }  
> },  
> "boost":1.5  
> }  
> },{  
> "constant\_score":{  
> "filter":{  
> "query":{  
> "prefix":{  
> "lastname":"foo"  
> }  
> }  
> },  
> "boost":1.2000000000000002  
> }  
> },{  
> "constant\_score":{  
> "filter":{  
> "query":{  
> "term":{  
> "lastname":"foo"  
> }  
> }  
> },  
> "boost":1.6  
> }  
> },{  
> "constant\_score":{  
> "filter":{  
> "query":{  
> "prefix":{  
> "firstname":"foo"  
> }  
> }  
> },  
> "boost":1.3000000000000003  
> }  
> },{  
> "constant\_score":{  
> "filter":{  
> "query":{  
> "term":{  
> "firstname":"foo"  
> }  
> }  
> },  
> "boost":1.7000000000000002  
> }  
> }]  
> }  
> },{  
> "dis\_max":{  
> "queries":[{  
> "constant\_score":{  
> "filter":{  
> "query":{  
> "prefix":{  
> "school":"bar"  
> }  
> }  
> },  
> "boost":1.0  
> }  
> },{  
> "constant\_score":{  
> "filter":{  
> "query":{  
> "term":{  
> "school":"bar"  
> }  
> }  
> },  
> "boost":1.4  
> }  
> },{  
> "constant\_score":{  
> "filter":{  
> "query":{  
> "prefix":{  
> "username":"bar"  
> }  
> }  
> },  
> "boost":1.1  
> }  
> },{  
> "constant\_score":{  
> "filter":{  
> "query":{  
> "term":{  
> "username":"bar"  
> }  
> }  
> },  
> "boost":1.5  
> }  
> },{  
> "constant\_score":{  
> "filter":{  
> "query":{  
> "prefix":{  
> "lastname":"bar"  
> }  
> }  
> },  
> "boost":1.2000000000000002  
> }  
> },{  
> "constant\_score":{  
> "filter":{  
> "query":{  
> "term":{  
> "lastname":"bar"  
> }  
> }  
> },  
> "boost":1.6  
> }  
> },{  
> "constant\_score":{  
> "filter":{  
> "query":{  
> "prefix":{  
> "firstname":"bar"  
> }  
> }  
> },  
> "boost":1.3000000000000003  
> }  
> },{  
> "constant\_score":{  
> "filter":{  
> "query":{  
> "term":{  
> "firstname":"bar"  
> }  
> }  
> },  
> "boost":1.7000000000000002  
> }  
> }]  
> }  
> }]  
> }  
> }  
> }

---

<div class="post-metadata">

### Author: ![Jacob\_Robertson\_2](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jacob_robertson_2/32/3332_2.png) [@Jacob\_Robertson\_2](https://discuss.elastic.co/u/Jacob_Robertson_2)
#### Post date: [July 14, 2010, 6:42pm UTC](https://discuss.elastic.co/t/disable-coord-in-bool-query-with-query-dsl/3099/3 "2010-07-14T18:42:05Z")

</div>

That was my problem. I didn't see anything about coord being disabled  
in ES. In Lucene it's fairly clearly documented with things like the  
BooleanQuery(boolean disableCoord) constructor. I saw nothing  
regarding it at all in the documentation for the query DSL. I figured  
out by trial and error that I could set "disableCoord" : true in the  
bool query, but that was not the product of documentation. Nonetheless  
it was inconsistent without that line, with half of the documents  
having scores that had been multiplied through by coord, and the other  
half not.

On Jul 14, 1:39 pm, Shay Banon [shay.ba...@elasticsearch.com](mailto:shay.ba...@elasticsearch.com) wrote:

> Where do you see coord being disabled? You can control it in elasticsearch  
> for boolean queries, but, by default, it is true.
> 
> -shay.banon
> 
> On Wed, Jul 14, 2010 at 6:20 PM, Jacob Robertson \<
> 
> [g.jacob.robert...@gmail.com](mailto:g.jacob.robert...@gmail.com)\> wrote:
> 
> > I am using a bool query to combine several dis\_max queries. I was  
> > getting some results in a rather unexpected order and went to check  
> > out the JSON returned by elasticsearch. Much to my surprise, on about  
> > half of the documents coming out of this bool query, the coord factor  
> > was not being applied. First of all assuming my query json is well-  
> > formed, this is rather inconsistent. Additionally is there a way with  
> > the query DSL to disable coord much like Lucene's BooleanQuery. The  
> > query I am sending to elasticsearch looks something like this
> 
> > {  
> > "query":{  
> > "bool":{  
> > "should":[{  
> > "dis\_max":{  
> > "queries":[{  
> > "constant\_score":{  
> > "filter":{  
> > "query":{  
> > "prefix":{  
> > "school":"foo"  
> > }  
> > }  
> > },  
> > "boost":1.0  
> > }  
> > },{  
> > "constant\_score":{  
> > "filter":{  
> > "query":{  
> > "term":{  
> > "school":"foo"  
> > }  
> > }  
> > },  
> > "boost":1.4  
> > }  
> > },{  
> > "constant\_score":{  
> > "filter":{  
> > "query":{  
> > "prefix":{  
> > "username":"foo"  
> > }  
> > }  
> > },  
> > "boost":1.1  
> > }  
> > },{  
> > "constant\_score":{  
> > "filter":{  
> > "query":{  
> > "term":{  
> > "username":"foo"  
> > }  
> > }  
> > },  
> > "boost":1.5  
> > }  
> > },{  
> > "constant\_score":{  
> > "filter":{  
> > "query":{  
> > "prefix":{  
> > "lastname":"foo"  
> > }  
> > }  
> > },  
> > "boost":1.2000000000000002  
> > }  
> > },{  
> > "constant\_score":{  
> > "filter":{  
> > "query":{  
> > "term":{  
> > "lastname":"foo"  
> > }  
> > }  
> > },  
> > "boost":1.6  
> > }  
> > },{  
> > "constant\_score":{  
> > "filter":{  
> > "query":{  
> > "prefix":{  
> > "firstname":"foo"  
> > }  
> > }  
> > },  
> > "boost":1.3000000000000003  
> > }  
> > },{  
> > "constant\_score":{  
> > "filter":{  
> > "query":{  
> > "term":{  
> > "firstname":"foo"  
> > }  
> > }  
> > },  
> > "boost":1.7000000000000002  
> > }  
> > }]  
> > }  
> > },{  
> > "dis\_max":{  
> > "queries":[{  
> > "constant\_score":{  
> > "filter":{  
> > "query":{  
> > "prefix":{  
> > "school":"bar"  
> > }  
> > }  
> > },  
> > "boost":1.0  
> > }  
> > },{  
> > "constant\_score":{  
> > "filter":{  
> > "query":{  
> > "term":{  
> > "school":"bar"  
> > }  
> > }  
> > },  
> > "boost":1.4  
> > }  
> > },{  
> > "constant\_score":{  
> > "filter":{  
> > "query":{  
> > "prefix":{  
> > "username":"bar"  
> > }  
> > }  
> > },  
> > "boost":1.1  
> > }  
> > },{  
> > "constant\_score":{  
> > "filter":{  
> > "query":{  
> > "term":{  
> > "username":"bar"  
> > }  
> > }  
> > },  
> > "boost":1.5  
> > }  
> > },{  
> > "constant\_score":{  
> > "filter":{  
> > "query":{  
> > "prefix":{  
> > "lastname":"bar"  
> > }  
> > }  
> > },  
> > "boost":1.2000000000000002  
> > }  
> > },{  
> > "constant\_score":{  
> > "filter":{  
> > "query":{  
> > "term":{  
> > "lastname":"bar"  
> > }  
> > }  
> > },  
> > "boost":1.6  
> > }  
> > },{  
> > "constant\_score":{  
> > "filter":{  
> > "query":{  
> > "prefix":{  
> > "firstname":"bar"  
> > }  
> > }  
> > },  
> > "boost":1.3000000000000003  
> > }  
> > },{  
> > "constant\_score":{  
> > "filter":{  
> > "query":{  
> > "term":{  
> > "firstname":"bar"  
> > }  
> > }  
> > },  
> > "boost":1.7000000000000002  
> > }  
> > }]  
> > }  
> > }]  
> > }  
> > }  
> > }

---

<div class="post-metadata">

### Author: ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)
#### Post date: [July 14, 2010, 7:09pm UTC](https://discuss.elastic.co/t/disable-coord-in-bool-query-with-query-dsl/3099/4 "2010-07-14T19:09:15Z")

</div>

I see, you wanted to disable coord for the boolean query. Yea, I forgot to  
add it to the boolean query doc. Added.

-shay.banon

On Wed, Jul 14, 2010 at 9:42 PM, Jacob Robertson \<  
[g.jacob.robertson@gmail.com](mailto:g.jacob.robertson@gmail.com)\> wrote:

> That was my problem. I didn't see anything about coord being disabled  
> in ES. In Lucene it's fairly clearly documented with things like the  
> BooleanQuery(boolean disableCoord) constructor. I saw nothing  
> regarding it at all in the documentation for the query DSL. I figured  
> out by trial and error that I could set "disableCoord" : true in the  
> bool query, but that was not the product of documentation. Nonetheless  
> it was inconsistent without that line, with half of the documents  
> having scores that had been multiplied through by coord, and the other  
> half not.
> 
> On Jul 14, 1:39 pm, Shay Banon [shay.ba...@elasticsearch.com](mailto:shay.ba...@elasticsearch.com) wrote:
> 
> > Where do you see coord being disabled? You can control it in  
> > elasticsearch  
> > for boolean queries, but, by default, it is true.
> > 
> > -shay.banon
> > 
> > On Wed, Jul 14, 2010 at 6:20 PM, Jacob Robertson \<
> > 
> > [g.jacob.robert...@gmail.com](mailto:g.jacob.robert...@gmail.com)\> wrote:
> > 
> > > I am using a bool query to combine several dis\_max queries. I was  
> > > getting some results in a rather unexpected order and went to check  
> > > out the JSON returned by elasticsearch. Much to my surprise, on about  
> > > half of the documents coming out of this bool query, the coord factor  
> > > was not being applied. First of all assuming my query json is well-  
> > > formed, this is rather inconsistent. Additionally is there a way with  
> > > the query DSL to disable coord much like Lucene's BooleanQuery. The  
> > > query I am sending to elasticsearch looks something like this
> > 
> > > {  
> > > "query":{  
> > > "bool":{  
> > > "should":[{  
> > > "dis\_max":{  
> > > "queries":[{  
> > > "constant\_score":{  
> > > "filter":{  
> > > "query":{  
> > > "prefix":{  
> > > "school":"foo"  
> > > }  
> > > }  
> > > },  
> > > "boost":1.0  
> > > }  
> > > },{  
> > > "constant\_score":{  
> > > "filter":{  
> > > "query":{  
> > > "term":{  
> > > "school":"foo"  
> > > }  
> > > }  
> > > },  
> > > "boost":1.4  
> > > }  
> > > },{  
> > > "constant\_score":{  
> > > "filter":{  
> > > "query":{  
> > > "prefix":{  
> > > "username":"foo"  
> > > }  
> > > }  
> > > },  
> > > "boost":1.1  
> > > }  
> > > },{  
> > > "constant\_score":{  
> > > "filter":{  
> > > "query":{  
> > > "term":{  
> > > "username":"foo"  
> > > }  
> > > }  
> > > },  
> > > "boost":1.5  
> > > }  
> > > },{  
> > > "constant\_score":{  
> > > "filter":{  
> > > "query":{  
> > > "prefix":{  
> > > "lastname":"foo"  
> > > }  
> > > }  
> > > },  
> > > "boost":1.2000000000000002  
> > > }  
> > > },{  
> > > "constant\_score":{  
> > > "filter":{  
> > > "query":{  
> > > "term":{  
> > > "lastname":"foo"  
> > > }  
> > > }  
> > > },  
> > > "boost":1.6  
> > > }  
> > > },{  
> > > "constant\_score":{  
> > > "filter":{  
> > > "query":{  
> > > "prefix":{  
> > > "firstname":"foo"  
> > > }  
> > > }  
> > > },  
> > > "boost":1.3000000000000003  
> > > }  
> > > },{  
> > > "constant\_score":{  
> > > "filter":{  
> > > "query":{  
> > > "term":{  
> > > "firstname":"foo"  
> > > }  
> > > }  
> > > },  
> > > "boost":1.7000000000000002  
> > > }  
> > > }]  
> > > }  
> > > },{  
> > > "dis\_max":{  
> > > "queries":[{  
> > > "constant\_score":{  
> > > "filter":{  
> > > "query":{  
> > > "prefix":{  
> > > "school":"bar"  
> > > }  
> > > }  
> > > },  
> > > "boost":1.0  
> > > }  
> > > },{  
> > > "constant\_score":{  
> > > "filter":{  
> > > "query":{  
> > > "term":{  
> > > "school":"bar"  
> > > }  
> > > }  
> > > },  
> > > "boost":1.4  
> > > }  
> > > },{  
> > > "constant\_score":{  
> > > "filter":{  
> > > "query":{  
> > > "prefix":{  
> > > "username":"bar"  
> > > }  
> > > }  
> > > },  
> > > "boost":1.1  
> > > }  
> > > },{  
> > > "constant\_score":{  
> > > "filter":{  
> > > "query":{  
> > > "term":{  
> > > "username":"bar"  
> > > }  
> > > }  
> > > },  
> > > "boost":1.5  
> > > }  
> > > },{  
> > > "constant\_score":{  
> > > "filter":{  
> > > "query":{  
> > > "prefix":{  
> > > "lastname":"bar"  
> > > }  
> > > }  
> > > },  
> > > "boost":1.2000000000000002  
> > > }  
> > > },{  
> > > "constant\_score":{  
> > > "filter":{  
> > > "query":{  
> > > "term":{  
> > > "lastname":"bar"  
> > > }  
> > > }  
> > > },  
> > > "boost":1.6  
> > > }  
> > > },{  
> > > "constant\_score":{  
> > > "filter":{  
> > > "query":{  
> > > "prefix":{  
> > > "firstname":"bar"  
> > > }  
> > > }  
> > > },  
> > > "boost":1.3000000000000003  
> > > }  
> > > },{  
> > > "constant\_score":{  
> > > "filter":{  
> > > "query":{  
> > > "term":{  
> > > "firstname":"bar"  
> > > }  
> > > }  
> > > },  
> > > "boost":1.7000000000000002  
> > > }  
> > > }]  
> > > }  
> > > }]  
> > > }  
> > > }  
> > > }

---

<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, 4:22am UTC](https://discuss.elastic.co/t/disable-coord-in-bool-query-with-query-dsl/3099/5 "2017-07-06T04:22:14Z")

</div>


