# Got QueryPhaseExecutionException when using custom query parser

**URL:** <https://discuss.elastic.co/t/got-queryphaseexecutionexception-when-using-custom-query-parser/19482>\
**Category:** Elasticsearch\
**Created:** [August 27, 2014, 5:44am UTC](https://discuss.elastic.co/t/got-queryphaseexecutionexception-when-using-custom-query-parser/19482 "2014-08-27T05:44:58Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Peiyong\_Lin](https://avatars.discourse-cdn.com/v4/letter/p/d26b3c/32.png) [@Peiyong\_Lin](https://discuss.elastic.co/u/Peiyong_Lin)\
**Post date:** [August 27, 2014, 5:44am UTC](https://discuss.elastic.co/t/got-queryphaseexecutionexception-when-using-custom-query-parser/19482/1 "2014-08-27T05:44:58Z")

</div>

Hi all,

I wrote my own custom query parser, and extended elasticsearch as a plugin,  
the code is in the following link.

query parser [http://pastebin.mozilla.org/6172836](http://pastebin.mozilla.org/6172836)  
customized query [http://pastebin.mozilla.org/6172837](http://pastebin.mozilla.org/6172837)  
plugin [http://pastebin.mozilla.org/6172844](http://pastebin.mozilla.org/6172844)

I used the default settings of Elasticsearch, and the document I PUT is  
{  
"test": "haha"  
}  
{  
"test": "ahah"  
}

I used the query:  
{  
"query": {  
"backwards": {  
"test": "haha"  
}  
}

And the error message I got is:

[2014-08-27 13:26:41,678][DEBUG][action.search.type] [Poison]  
[test][2], node[w4ORe\_ERQBeOVpII3P9w1w], [P], s[STARTED]: Failed to execute  
[org.elasticsearch.action.search.SearchRequest@7e1416e] lastShard [true]  
org.elasticsearch.search.query.QueryPhaseExecutionException: [test][2]:  
query[filtered(BackwardsQuery:  
test:ahah)-\>cache(\_type:test)],from[0],size[10]: Query Failed [Failed to  
execute main query]  
at  
org.elasticsearch.search.query.QueryPhase.execute(QueryPhase.java:162)  
at  
org.elasticsearch.search.SearchService.executeQueryPhase(SearchService.java:261)  
at  
org.elasticsearch.search.action.SearchServiceTransportAction$5.call(SearchServiceTransportAction.java:206)  
at  
org.elasticsearch.search.action.SearchServiceTransportAction$5.call(SearchServiceTransportAction.java:203)  
at  
org.elasticsearch.search.action.SearchServiceTransportAction$23.run(SearchServiceTransportAction.java:517)  
at  
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)  
at  
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)  
at java.lang.Thread.run(Thread.java:745)  
Caused by: java.lang.NullPointerException  
at  
org.elasticsearch.backwardstermquery.BackwardsTermQuery$BackwardsScorer.docID(BackwardsTermQuery.java:118)  
at  
org.elasticsearch.backwardstermquery.BackwardsTermQuery$BackwardsScorer.nextDoc(BackwardsTermQuery.java:133)  
at  
org.apache.lucene.search.Weight$DefaultBulkScorer.scoreAll(Weight.java:192)  
at  
org.apache.lucene.search.Weight$DefaultBulkScorer.score(Weight.java:163)  
at org.apache.lucene.search.BulkScorer.score(BulkScorer.java:35)  
at  
org.apache.lucene.search.IndexSearcher.search(IndexSearcher.java:621)  
at  
org.elasticsearch.search.internal.ContextIndexSearcher.search(ContextIndexSearcher.java:175)  
at  
org.apache.lucene.search.IndexSearcher.search(IndexSearcher.java:491)  
at  
org.apache.lucene.search.IndexSearcher.search(IndexSearcher.java:448)  
at  
org.apache.lucene.search.IndexSearcher.search(IndexSearcher.java:281)  
at  
org.apache.lucene.search.IndexSearcher.search(IndexSearcher.java:269)  
at  
org.elasticsearch.search.query.QueryPhase.execute(QueryPhase.java:156)  
... 7 more

I am very confused of it, could someone please point out what's wrong?  
Thank you so much!

--  
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).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/2082f731-34c5-4d92-9fe0-439cef5fdabc%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/2082f731-34c5-4d92-9fe0-439cef5fdabc%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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, 1:06am UTC](https://discuss.elastic.co/t/got-queryphaseexecutionexception-when-using-custom-query-parser/19482/2 "2017-07-06T01:06:07Z")

</div>


