# Query fails because of NullPointerException in QueryPhase

**URL:** <https://discuss.elastic.co/t/query-fails-because-of-nullpointerexception-in-queryphase/4236>\
**Category:** Elasticsearch\
**Created:** [April 14, 2011, 1:50pm UTC](https://discuss.elastic.co/t/query-fails-because-of-nullpointerexception-in-queryphase/4236 "2011-04-14T13:50:32Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Michel\_Conrad](https://avatars.discourse-cdn.com/v4/letter/m/5e9695/32.png) [@Michel\_Conrad](https://discuss.elastic.co/u/Michel_Conrad)\
**Post date:** [April 14, 2011, 1:50pm UTC](https://discuss.elastic.co/t/query-fails-because-of-nullpointerexception-in-queryphase/4236/1 "2011-04-14T13:50:32Z")

</div>

Hi, I am getting the following NullPointerException while searching, I  
am using the master branch (rev 25eba4b6):

[2011-04-14 15:44:38,756][DEBUG][action.search.type] [Calypso]  
[19734] Failed to execute query phase  
org.elasticsearch.search.query.QueryPhaseExecutionException:  
[dsearch\_all\_3ae4][1]: query[(content\_text:"doku soap"  
content\_text:fotos content\_text:brÃ¼der) content\_text:"tank  
team"^2.0],from[0],size[10]: Query Failed [Failed to execute main  
query]  
at org.elasticsearch.search.query.QueryPhase.execute(QueryPhase.java:215)  
at org.elasticsearch.search.SearchService.executeQueryPhase(SearchService.java:261)  
at org.elasticsearch.search.action.SearchServiceTransportAction.sendExecuteQuery(SearchServiceTransportAction.java:164)  
at org.elasticsearch.action.search.type.TransportSearchDfsQueryThenFetchAction$AsyncAction.executeQuery(TransportSearchDfsQueryThenFetchAction.java:140)  
at org.elasticsearch.action.search.type.TransportSearchDfsQueryThenFetchAction$AsyncAction.access$200(TransportSearchDfsQueryThenFetchAction.java:63)  
at org.elasticsearch.action.search.type.TransportSearchDfsQueryThenFetchAction$AsyncAction$2.run(TransportSearchDfsQueryThenFetchAction.java:127)  
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)  
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)  
at java.lang.Thread.run(Thread.java:662)  
Caused by: java.lang.NullPointerException  
at org.elasticsearch.index.cache.filter.support.AbstractConcurrentMapFilterCache$CacheMapEvictionListener.onEviction(AbstractConcurrentMapFilterCache.java:263)  
at org.elasticsearch.index.cache.filter.support.AbstractConcurrentMapFilterCache$CacheMapEvictionListener.onEviction(AbstractConcurrentMapFilterCache.java:254)  
at org.elasticsearch.common.collect.CustomConcurrentHashMap.processPendingNotifications(CustomConcurrentHashMap.java:1501)  
at org.elasticsearch.common.collect.CustomConcurrentHashMap$Segment.put(CustomConcurrentHashMap.java:2179)  
at org.elasticsearch.common.collect.CustomConcurrentHashMap.putIfAbsent(CustomConcurrentHashMap.java:2593)  
at org.elasticsearch.index.cache.filter.support.AbstractConcurrentMapFilterCache$FilterCacheFilterWrapper.getDocIdSet(AbstractConcurrentMapFilterCache.java:162)  
at org.apache.lucene.search.FilteredQuery$1.scorer(FilteredQuery.java:120)  
at org.apache.lucene.search.IndexSearcher.search(IndexSearcher.java:517)  
at org.elasticsearch.search.internal.ContextIndexSearcher.search(ContextIndexSearcher.java:169)  
at org.apache.lucene.search.IndexSearcher.search(IndexSearcher.java:384)  
at org.apache.lucene.search.IndexSearcher.search(IndexSearcher.java:291)  
at org.apache.lucene.search.IndexSearcher.search(IndexSearcher.java:279)  
at org.elasticsearch.search.query.QueryPhase.execute(QueryPhase.java:211)  
... 8 more

---

<div class="post-metadata">

**Author:** ![Clinton\_Gormley](https://avatars.discourse-cdn.com/v4/letter/c/50afbb/32.png) [@Clinton\_Gormley](https://discuss.elastic.co/u/Clinton_Gormley)\
**Post date:** [April 14, 2011, 2:11pm UTC](https://discuss.elastic.co/t/query-fails-because-of-nullpointerexception-in-queryphase/4236/2 "2011-04-14T14:11:12Z")

</div>

Hi Michael

I don't know if this has anything to do with your problem, but it looks  
like you're not passing UTF8-encoded text to Elasticsearch:

> [2011-04-14 15:44:38,756][DEBUG][action.search.type] [Calypso]  
> [19734] Failed to execute query phase  
> org.elasticsearch.search.query.QueryPhaseExecutionException:  
> [dsearch\_all\_3ae4][1]: query[(content\_text:"doku soap"  
> content\_text:fotos content\_text:brÃÂ¼der) content\_text:"tank

```
                            ^^

```

does it work if you don't include that term?

clint

---

<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:** [April 14, 2011, 4:13pm UTC](https://discuss.elastic.co/t/query-fails-because-of-nullpointerexception-in-queryphase/4236/3 "2011-04-14T16:13:48Z")

</div>

Ahh, I see where it happens..., will push a fix for it soon.  
On Thursday, April 14, 2011 at 4:50 PM, Michel Conrad wrote:

> AbstractConcurrentMapFilterCache.java

---

<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:** [April 14, 2011, 5:20pm UTC](https://discuss.elastic.co/t/query-fails-because-of-nullpointerexception-in-queryphase/4236/4 "2011-04-14T17:20:51Z")

</div>

Pushed a fix.  
On Thursday, April 14, 2011 at 7:13 PM, Shay Banon wrote:

> Ahh, I see where it happens..., will push a fix for it soon.  
> On Thursday, April 14, 2011 at 4:50 PM, Michel Conrad wrote:
> 
> > AbstractConcurrentMapFilterCache.java

---

<div class="post-metadata">

**Author:** ![Michel\_Conrad](https://avatars.discourse-cdn.com/v4/letter/m/5e9695/32.png) [@Michel\_Conrad](https://discuss.elastic.co/u/Michel_Conrad)\
**Post date:** [April 14, 2011, 5:51pm UTC](https://discuss.elastic.co/t/query-fails-because-of-nullpointerexception-in-queryphase/4236/5 "2011-04-14T17:51:20Z")

</div>

Thanks for the patch, I just tried it out and the exception is gone.

Although now I get another exception in the same context, I am using  
up to 50 connections at once using a single client:  
Could it be a concurrency problem?

[2011-04-14 19:45:55,676][DEBUG][action.search.type] [Reject]  
[72] Failed to execute fetch phase  
org.elasticsearch.transport.RemoteTransportException:  
[Kirigi][inet[/192.168.1.191:9300]][search/phase/fetch/id]  
Caused by: org.elasticsearch.search.SearchContextMissingException: No  
search context found for id [72]  
at org.elasticsearch.search.SearchService.findContext(SearchService.java:367)  
at org.elasticsearch.search.SearchService.executeFetchPhase(SearchService.java:345)  
at org.elasticsearch.search.action.SearchServiceTransportAction$SearchFetchByIdTransportHandler.messageReceived(SearchServiceTransportAction.java:537)  
at org.elasticsearch.search.action.SearchServiceTransportAction$SearchFetchByIdTransportHandler.messageReceived(SearchServiceTransportAction.java:528)  
at org.elasticsearch.transport.netty.MessageChannelHandler$RequestHandler.run(MessageChannelHandler.java:236)  
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)  
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)  
at java.lang.Thread.run(Thread.java:662)  
RemoteTransportException[[Kirigi][inet[/192.168.1.191:9300]][search/phase/fetch/id]];  
nested: SearchContextMissingException[No search context found for id  
[72]];

On Thu, Apr 14, 2011 at 7:20 PM, Shay Banon  
[shay.banon@elasticsearch.com](mailto:shay.banon@elasticsearch.com) wrote:

> Pushed a fix.
> 
> On Thursday, April 14, 2011 at 7:13 PM, Shay Banon wrote:
> 
> Ahh, I see where it happens..., will push a fix for it soon.
> 
> On Thursday, April 14, 2011 at 4:50 PM, Michel Conrad wrote:
> 
> AbstractConcurrentMapFilterCache.java

---

<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:** [April 14, 2011, 5:54pm UTC](https://discuss.elastic.co/t/query-fails-because-of-nullpointerexception-in-queryphase/4236/6 "2011-04-14T17:54:05Z")

</div>

Might be, the context is by default timed out (between the query and fetch phase) after 5 minutes, but I doubt its the case. Can you recreate it in a standalone testcase?  
On Thursday, April 14, 2011 at 8:51 PM, Michel Conrad wrote:

> Thanks for the patch, I just tried it out and the exception is gone.
> 
> Although now I get another exception in the same context, I am using  
> up to 50 connections at once using a single client:  
> Could it be a concurrency problem?
> 
> [2011-04-14 19:45:55,676][DEBUG][action.search.type] [Reject]  
> [72] Failed to execute fetch phase  
> org.elasticsearch.transport.RemoteTransportException:  
> [Kirigi][inet[/192.168.1.191:9300]][search/phase/fetch/id]  
> Caused by: org.elasticsearch.search.SearchContextMissingException: No  
> search context found for id [72]  
> at org.elasticsearch.search.SearchService.findContext(SearchService.java:367)  
> at org.elasticsearch.search.SearchService.executeFetchPhase(SearchService.java:345)  
> at org.elasticsearch.search.action.SearchServiceTransportAction$SearchFetchByIdTransportHandler.messageReceived(SearchServiceTransportAction.java:537)  
> at org.elasticsearch.search.action.SearchServiceTransportAction$SearchFetchByIdTransportHandler.messageReceived(SearchServiceTransportAction.java:528)  
> at org.elasticsearch.transport.netty.MessageChannelHandler$RequestHandler.run(MessageChannelHandler.java:236)  
> at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)  
> at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)  
> at java.lang.Thread.run(Thread.java:662)  
> RemoteTransportException[[Kirigi][inet[/192.168.1.191:9300]][search/phase/fetch/id]];  
> nested: SearchContextMissingException[No search context found for id  
> [72]];
> 
> On Thu, Apr 14, 2011 at 7:20 PM, Shay Banon  
> [shay.banon@elasticsearch.com](mailto:shay.banon@elasticsearch.com) wrote:
> 
> > Pushed a fix.
> > 
> > On Thursday, April 14, 2011 at 7:13 PM, Shay Banon wrote:
> > 
> > Ahh, I see where it happens..., will push a fix for it soon.
> > 
> > On Thursday, April 14, 2011 at 4:50 PM, Michel Conrad wrote:
> > 
> > AbstractConcurrentMapFilterCache.java

---

<div class="post-metadata">

**Author:** ![Michel\_Conrad](https://avatars.discourse-cdn.com/v4/letter/m/5e9695/32.png) [@Michel\_Conrad](https://discuss.elastic.co/u/Michel_Conrad)\
**Post date:** [April 15, 2011, 12:33pm UTC](https://discuss.elastic.co/t/query-fails-because-of-nullpointerexception-in-queryphase/4236/7 "2011-04-15T12:33:06Z")

</div>

Hi, I haven't been able to recreate the issue. Thanks for the clarification.

On Thu, Apr 14, 2011 at 7:54 PM, Shay Banon  
[shay.banon@elasticsearch.com](mailto:shay.banon@elasticsearch.com) wrote:

> Might be, the context is by default timed out (between the query and fetch  
> phase) after 5 minutes, but I doubt its the case. Can you recreate it in a  
> standalone testcase?
> 
> On Thursday, April 14, 2011 at 8:51 PM, Michel Conrad wrote:
> 
> Thanks for the patch, I just tried it out and the exception is gone.
> 
> Although now I get another exception in the same context, I am using  
> up to 50 connections at once using a single client:  
> Could it be a concurrency problem?
> 
> [2011-04-14 19:45:55,676][DEBUG][action.search.type] [Reject]  
> [72] Failed to execute fetch phase  
> org.elasticsearch.transport.RemoteTransportException:  
> [Kirigi][inet[/192.168.1.191:9300]][search/phase/fetch/id]  
> Caused by: org.elasticsearch.search.SearchContextMissingException: No  
> search context found for id [72]  
> at  
> org.elasticsearch.search.SearchService.findContext(SearchService.java:367)  
> at  
> org.elasticsearch.search.SearchService.executeFetchPhase(SearchService.java:345)  
> at  
> org.elasticsearch.search.action.SearchServiceTransportAction$SearchFetchByIdTransportHandler.messageReceived(SearchServiceTransportAction.java:537)  
> at  
> org.elasticsearch.search.action.SearchServiceTransportAction$SearchFetchByIdTransportHandler.messageReceived(SearchServiceTransportAction.java:528)  
> at  
> org.elasticsearch.transport.netty.MessageChannelHandler$$RequestHandler.run(MessageChannelHandler.java:236)  
> at  
> java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)  
> at  
> java.util.concurrent.ThreadPoolExecutor$$Worker.run(ThreadPoolExecutor.java:908)  
> at java.lang.Thread.run(Thread.java:662)  
> RemoteTransportException[[Kirigi][inet[/192.168.1.191:9300]][search/phase/fetch/id]];  
> nested: SearchContextMissingException[No search context found for id  
> [72]];
> 
> On Thu, Apr 14, 2011 at 7:20 PM, Shay Banon  
> [shay.banon@elasticsearch.com](mailto:shay.banon@elasticsearch.com) wrote:
> 
> Pushed a fix.
> 
> On Thursday, April 14, 2011 at 7:13 PM, Shay Banon wrote:
> 
> Ahh, I see where it happens..., will push a fix for it soon.
> 
> On Thursday, April 14, 2011 at 4:50 PM, Michel Conrad wrote:
> 
> AbstractConcurrentMapFilterCache.java

---

<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:** [April 15, 2011, 4:52pm UTC](https://discuss.elastic.co/t/query-fails-because-of-nullpointerexception-in-queryphase/4236/8 "2011-04-15T16:52:20Z")

</div>

Damn, was hoping you could :). Well, if it happens again, ping me. Had another look, and ran some of the stress tests I have and things worked well.  
On Friday, April 15, 2011 at 3:33 PM, Michel Conrad wrote:

> Hi, I haven't been able to recreate the issue. Thanks for the clarification.
> 
> On Thu, Apr 14, 2011 at 7:54 PM, Shay Banon  
> [shay.banon@elasticsearch.com](mailto:shay.banon@elasticsearch.com) wrote:
> 
> > Might be, the context is by default timed out (between the query and fetch  
> > phase) after 5 minutes, but I doubt its the case. Can you recreate it in a  
> > standalone testcase?
> > 
> > On Thursday, April 14, 2011 at 8:51 PM, Michel Conrad wrote:
> > 
> > Thanks for the patch, I just tried it out and the exception is gone.
> > 
> > Although now I get another exception in the same context, I am using  
> > up to 50 connections at once using a single client:  
> > Could it be a concurrency problem?
> > 
> > [2011-04-14 19:45:55,676][DEBUG][action.search.type] [Reject]  
> > [72] Failed to execute fetch phase  
> > org.elasticsearch.transport.RemoteTransportException:  
> > [Kirigi][inet[/192.168.1.191:9300]][search/phase/fetch/id]  
> > Caused by: org.elasticsearch.search.SearchContextMissingException: No  
> > search context found for id [72]  
> > at  
> > org.elasticsearch.search.SearchService.findContext(SearchService.java:367)  
> > at  
> > org.elasticsearch.search.SearchService.executeFetchPhase(SearchService.java:345)  
> > at  
> > org.elasticsearch.search.action.SearchServiceTransportAction$SearchFetchByIdTransportHandler.messageReceived(SearchServiceTransportAction.java:537)  
> > at  
> > org.elasticsearch.search.action.SearchServiceTransportAction$SearchFetchByIdTransportHandler.messageReceived(SearchServiceTransportAction.java:528)  
> > at  
> > org.elasticsearch.transport.netty.MessageChannelHandler$$RequestHandler.run(MessageChannelHandler.java:236)  
> > at  
> > java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)  
> > at  
> > java.util.concurrent.ThreadPoolExecutor$$Worker.run(ThreadPoolExecutor.java:908)  
> > at java.lang.Thread.run(Thread.java:662)  
> > RemoteTransportException[[Kirigi][inet[/192.168.1.191:9300]][search/phase/fetch/id]];  
> > nested: SearchContextMissingException[No search context found for id  
> > [72]];
> > 
> > On Thu, Apr 14, 2011 at 7:20 PM, Shay Banon  
> > [shay.banon@elasticsearch.com](mailto:shay.banon@elasticsearch.com) wrote:
> > 
> > Pushed a fix.
> > 
> > On Thursday, April 14, 2011 at 7:13 PM, Shay Banon wrote:
> > 
> > Ahh, I see where it happens..., will push a fix for it soon.
> > 
> > On Thursday, April 14, 2011 at 4:50 PM, Michel Conrad wrote:
> > 
> > AbstractConcurrentMapFilterCache.java

---

<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:08am UTC](https://discuss.elastic.co/t/query-fails-because-of-nullpointerexception-in-queryphase/4236/9 "2017-07-06T04:08:17Z")

</div>


