# Query never returns

**URL:** <https://discuss.elastic.co/t/query-never-returns/6745>\
**Category:** Elasticsearch\
**Created:** [February 18, 2012, 6:43pm UTC](https://discuss.elastic.co/t/query-never-returns/6745 "2012-02-18T18:43:07Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![mattweber](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mattweber/32/44940_2.png) [@mattweber](https://discuss.elastic.co/u/mattweber)\
**Post date:** [February 18, 2012, 6:43pm UTC](https://discuss.elastic.co/t/query-never-returns/6745/1 "2012-02-18T18:43:07Z")

</div>

I have a need to make sure all hits from a specific field in a specific type are always the highest ranked documents. To do this, I have used a constant score query with a really high boost value against this type. At the same time, I still want to search across other types and fields in my index. I have crafted a boolean query with 2 should clauses. The first contains the constant score query and the second contains a query string query. Everything works as expected until my constant score query uses a filter. When I specify a filter, the query locks up and never returns a response.

The only reason I decided to use a filter was for better performance. If I remove the 2nd clause from the boolean query, the search executes just fine. If I leave the 2nd clause, and remove the filter from the constant score query, it also returns fine. If I do the constant score filter query by itself, it also returns the expected query.

Here is a gist with the simplest example of the problem:

> <https://gist.github.com/mattweber/1860568>
>
> There are more than three files. show original

I am testing with 0.19.0.RC2.

--  
Matt Weber  
Sent with Sparrow ([http://www.sparrowmailapp.com/?sig](http://www.sparrowmailapp.com/?sig))

---

<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:** [February 20, 2012, 1:05pm UTC](https://discuss.elastic.co/t/query-never-returns/6745/2 "2012-02-20T13:05:21Z")

</div>

Regarding the recreation, I ran it against a simple index, and it doesn't lock up, can you provide a recreation that shows the lock up starting fresh (possibly indexing sample docs)?

Regarding boosting specific type, you can use the custom filters score query ([http://www.elasticsearch.org/guide/reference/query-dsl/custom-filters-score-query.html](http://www.elasticsearch.org/guide/reference/query-dsl/custom-filters-score-query.html)), and have a term filter on \_type that boosts the score if the document matches that type.

On Saturday, February 18, 2012 at 8:43 PM, Matt Weber wrote:

> I have a need to make sure all hits from a specific field in a specific type are always the highest ranked documents. To do this, I have used a constant score query with a really high boost value against this type. At the same time, I still want to search across other types and fields in my index. I have crafted a boolean query with 2 should clauses. The first contains the constant score query and the second contains a query string query. Everything works as expected until my constant score query uses a filter. When I specify a filter, the query locks up and never returns a response.
> 
> The only reason I decided to use a filter was for better performance. If I remove the 2nd clause from the boolean query, the search executes just fine. If I leave the 2nd clause, and remove the filter from the constant score query, it also returns fine. If I do the constant score filter query by itself, it also returns the expected query.
> 
> Here is a gist with the simplest example of the problem:  
> [failed query (has filter) · GitHub](https://gist.github.com/1860568)
> 
> I am testing with 0.19.0.RC2.
> 
> --  
> Matt Weber  
> Sent with Sparrow ([http://www.sparrowmailapp.com/?sig](http://www.sparrowmailapp.com/?sig))

---

<div class="post-metadata">

**Author:** ![mattweber](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mattweber/32/44940_2.png) [@mattweber](https://discuss.elastic.co/u/mattweber)\
**Post date:** [February 20, 2012, 3:19pm UTC](https://discuss.elastic.co/t/query-never-returns/6745/3 "2012-02-20T15:19:37Z")

</div>

The gist has the sample docs and sample query that locks it up. Just to double check I installed a fresh copy 0.19.0.RC2, started it, copy and pasted the test docs from the gist, then copy and pasted the query from the gist and it locked up.

> <https://gist.github.com/mattweber/1860568>
>
> There are more than three files. show original

--  
Matt Weber  
Sent with Sparrow ([http://www.sparrowmailapp.com/?sig](http://www.sparrowmailapp.com/?sig))

On Monday, February 20, 2012 at 5:05 AM, Shay Banon wrote:

> Regarding the recreation, I ran it against a simple index, and it doesn't lock up, can you provide a recreation that shows the lock up starting fresh (possibly indexing sample docs)?
> 
> Regarding boosting specific type, you can use the custom filters score query ([http://www.elasticsearch.org/guide/reference/query-dsl/custom-filters-score-query.html](http://www.elasticsearch.org/guide/reference/query-dsl/custom-filters-score-query.html)), and have a term filter on \_type that boosts the score if the document matches that type.
> 
> On Saturday, February 18, 2012 at 8:43 PM, Matt Weber wrote:
> 
> > I have a need to make sure all hits from a specific field in a specific type are always the highest ranked documents. To do this, I have used a constant score query with a really high boost value against this type. At the same time, I still want to search across other types and fields in my index. I have crafted a boolean query with 2 should clauses. The first contains the constant score query and the second contains a query string query. Everything works as expected until my constant score query uses a filter. When I specify a filter, the query locks up and never returns a response.
> > 
> > The only reason I decided to use a filter was for better performance. If I remove the 2nd clause from the boolean query, the search executes just fine. If I leave the 2nd clause, and remove the filter from the constant score query, it also returns fine. If I do the constant score filter query by itself, it also returns the expected query.
> > 
> > Here is a gist with the simplest example of the problem:  
> > [failed query (has filter) · GitHub](https://gist.github.com/1860568)
> > 
> > I am testing with 0.19.0.RC2.
> > 
> > --  
> > Matt Weber  
> > Sent with Sparrow ([http://www.sparrowmailapp.com/?sig](http://www.sparrowmailapp.com/?sig))

---

<div class="post-metadata">

**Author:** ![egaumer](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/egaumer/32/2365_2.png) [@egaumer](https://discuss.elastic.co/u/egaumer)\
**Post date:** [February 20, 2012, 9:36pm UTC](https://discuss.elastic.co/t/query-never-returns/6745/4 "2012-02-20T21:36:33Z")

</div>

I was able to reproduce this based on the gist. Debug logs don't show  
anything but the CPU spikes (when you run the query) and never comes back  
down (even when you kill the query). You actually have to restart  
elasticsearch.

---

<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:** [February 21, 2012, 4:29pm UTC](https://discuss.elastic.co/t/query-never-returns/6745/5 "2012-02-21T16:29:06Z")

</div>

It seems like its stuck in a look within Lucene boolean query, still need to chase it more and figure out what goes wrong, can you open an issue just so we won't loose it?

On Monday, February 20, 2012 at 5:19 PM, Matt Weber wrote:

> The gist has the sample docs and sample query that locks it up. Just to double check I installed a fresh copy 0.19.0.RC2, started it, copy and pasted the test docs from the gist, then copy and pasted the query from the gist and it locked up.
> 
> [failed query (has filter) · GitHub](https://gist.github.com/1860568)
> 
> --  
> Matt Weber  
> Sent with Sparrow ([http://www.sparrowmailapp.com/?sig](http://www.sparrowmailapp.com/?sig))
> 
> On Monday, February 20, 2012 at 5:05 AM, Shay Banon wrote:
> 
> > Regarding the recreation, I ran it against a simple index, and it doesn't lock up, can you provide a recreation that shows the lock up starting fresh (possibly indexing sample docs)?
> > 
> > Regarding boosting specific type, you can use the custom filters score query ([http://www.elasticsearch.org/guide/reference/query-dsl/custom-filters-score-query.html](http://www.elasticsearch.org/guide/reference/query-dsl/custom-filters-score-query.html)), and have a term filter on \_type that boosts the score if the document matches that type.
> > 
> > On Saturday, February 18, 2012 at 8:43 PM, Matt Weber wrote:
> > 
> > > I have a need to make sure all hits from a specific field in a specific type are always the highest ranked documents. To do this, I have used a constant score query with a really high boost value against this type. At the same time, I still want to search across other types and fields in my index. I have crafted a boolean query with 2 should clauses. The first contains the constant score query and the second contains a query string query. Everything works as expected until my constant score query uses a filter. When I specify a filter, the query locks up and never returns a response.
> > > 
> > > The only reason I decided to use a filter was for better performance. If I remove the 2nd clause from the boolean query, the search executes just fine. If I leave the 2nd clause, and remove the filter from the constant score query, it also returns fine. If I do the constant score filter query by itself, it also returns the expected query.
> > > 
> > > Here is a gist with the simplest example of the problem:  
> > > [failed query (has filter) · GitHub](https://gist.github.com/1860568)
> > > 
> > > I am testing with 0.19.0.RC2.
> > > 
> > > --  
> > > Matt Weber  
> > > Sent with Sparrow ([http://www.sparrowmailapp.com/?sig](http://www.sparrowmailapp.com/?sig))

---

<div class="post-metadata">

**Author:** ![Ivan](https://avatars.discourse-cdn.com/v4/letter/i/df788c/32.png) [@Ivan](https://discuss.elastic.co/u/Ivan)\
**Post date:** [February 21, 2012, 5:17pm UTC](https://discuss.elastic.co/t/query-never-returns/6745/6 "2012-02-21T17:17:58Z")

</div>

I have seen queries not returning if there are older versions of  
Lucene in the classpath. Not every query uses every Lucene  
class/method. Certain queries might use a different method, and if the  
previous version of Lucene does not have that method, a query to ES  
will simply hang with no exception thrown on the client or server  
side.

--  
Ivan

On Tue, Feb 21, 2012 at 8:29 AM, Shay Banon [kimchy@gmail.com](mailto:kimchy@gmail.com) wrote:

> It seems like its stuck in a look within Lucene boolean query, still need to  
> chase it more and figure out what goes wrong, can you open an issue just so  
> we won't loose it?
> 
> On Monday, February 20, 2012 at 5:19 PM, Matt Weber wrote:
> 
> The gist has the sample docs and sample query that locks it up. Just to  
> double check I installed a fresh copy 0.19.0.RC2, started it, copy and  
> pasted the test docs from the gist, then copy and pasted the query from the  
> gist and it locked up.
> 
> [failed query (has filter) · GitHub](https://gist.github.com/1860568)
> 
> --  
> Matt Weber  
> Sent with Sparrow
> 
> On Monday, February 20, 2012 at 5:05 AM, Shay Banon wrote:
> 
> Regarding the recreation, I ran it against a simple index, and it doesn't  
> lock up, can you provide a recreation that shows the lock up starting fresh  
> (possibly indexing sample docs)?
> 
> Regarding boosting specific type, you can use the custom filters score query  
> ([http://www.elasticsearch.org/guide/reference/query-dsl/custom-filters-score-query.html](http://www.elasticsearch.org/guide/reference/query-dsl/custom-filters-score-query.html)),  
> and have a term filter on \_type that boosts the score if the document  
> matches that type.
> 
> On Saturday, February 18, 2012 at 8:43 PM, Matt Weber wrote:
> 
> I have a need to make sure all hits from a specific field in a specific type  
> are always the highest ranked documents. To do this, I have used a constant  
> score query with a really high boost value against this type. At the same  
> time, I still want to search across other types and fields in my index. I  
> have crafted a boolean query with 2 should clauses. The first contains the  
> constant score query and the second contains a query string query.  
> Everything works as expected until my constant score query uses a filter.  
> When I specify a filter, the query locks up and never returns a response.
> 
> The only reason I decided to use a filter was for better performance. If I  
> remove the 2nd clause from the boolean query, the search executes just fine.  
> If I leave the 2nd clause, and remove the filter from the constant score  
> query, it also returns fine. If I do the constant score filter query by  
> itself, it also returns the expected query.
> 
> Here is a gist with the simplest example of the problem:  
> [failed query (has filter) · GitHub](https://gist.github.com/1860568)
> 
> I am testing with 0.19.0.RC2.
> 
> --  
> Matt Weber  
> Sent with Sparrow

---

<div class="post-metadata">

**Author:** ![mattweber](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mattweber/32/44940_2.png) [@mattweber](https://discuss.elastic.co/u/mattweber)\
**Post date:** [February 21, 2012, 8:23pm UTC](https://discuss.elastic.co/t/query-never-returns/6745/7 "2012-02-21T20:23:30Z")

</div>

Thanks!

> <https://github.com/elastic/elasticsearch/issues/1725>
>
> When executing a boolean query that contains a constant score query filter, the …query appears to lock up elasticsearch or lucene and never return a response. Details how to reproduce can be found in the following gist:
> 
> https://gist.github.com/1860568

--  
Matt Weber  
Sent with Sparrow ([http://www.sparrowmailapp.com/?sig](http://www.sparrowmailapp.com/?sig))

On Tuesday, February 21, 2012 at 9:17 AM, Ivan Brusic wrote:

> I have seen queries not returning if there are older versions of  
> Lucene in the classpath. Not every query uses every Lucene  
> class/method. Certain queries might use a different method, and if the  
> previous version of Lucene does not have that method, a query to ES  
> will simply hang with no exception thrown on the client or server  
> side.
> 
> --  
> Ivan
> 
> On Tue, Feb 21, 2012 at 8:29 AM, Shay Banon \<[kimchy@gmail.com](mailto:kimchy@gmail.com) ([mailto:kimchy@gmail.com](mailto:kimchy@gmail.com))\> wrote:
> 
> > It seems like its stuck in a look within Lucene boolean query, still need to  
> > chase it more and figure out what goes wrong, can you open an issue just so  
> > we won't loose it?
> > 
> > On Monday, February 20, 2012 at 5:19 PM, Matt Weber wrote:
> > 
> > The gist has the sample docs and sample query that locks it up. Just to  
> > double check I installed a fresh copy 0.19.0.RC2, started it, copy and  
> > pasted the test docs from the gist, then copy and pasted the query from the  
> > gist and it locked up.
> > 
> > [failed query (has filter) · GitHub](https://gist.github.com/1860568)
> > 
> > --  
> > Matt Weber  
> > Sent with Sparrow
> > 
> > On Monday, February 20, 2012 at 5:05 AM, Shay Banon wrote:
> > 
> > Regarding the recreation, I ran it against a simple index, and it doesn't  
> > lock up, can you provide a recreation that shows the lock up starting fresh  
> > (possibly indexing sample docs)?
> > 
> > Regarding boosting specific type, you can use the custom filters score query  
> > ([http://www.elasticsearch.org/guide/reference/query-dsl/custom-filters-score-query.html](http://www.elasticsearch.org/guide/reference/query-dsl/custom-filters-score-query.html)),  
> > and have a term filter on \_type that boosts the score if the document  
> > matches that type.
> > 
> > On Saturday, February 18, 2012 at 8:43 PM, Matt Weber wrote:
> > 
> > I have a need to make sure all hits from a specific field in a specific type  
> > are always the highest ranked documents. To do this, I have used a constant  
> > score query with a really high boost value against this type. At the same  
> > time, I still want to search across other types and fields in my index. I  
> > have crafted a boolean query with 2 should clauses. The first contains the  
> > constant score query and the second contains a query string query.  
> > Everything works as expected until my constant score query uses a filter.  
> > When I specify a filter, the query locks up and never returns a response.
> > 
> > The only reason I decided to use a filter was for better performance. If I  
> > remove the 2nd clause from the boolean query, the search executes just fine.  
> > If I leave the 2nd clause, and remove the filter from the constant score  
> > query, it also returns fine. If I do the constant score filter query by  
> > itself, it also returns the expected query.
> > 
> > Here is a gist with the simplest example of the problem:  
> > [failed query (has filter) · GitHub](https://gist.github.com/1860568)
> > 
> > I am testing with 0.19.0.RC2.
> > 
> > --  
> > Matt Weber  
> > Sent with Sparrow

---

<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:38am UTC](https://discuss.elastic.co/t/query-never-returns/6745/8 "2017-07-06T03:38:39Z")

</div>


