# UnsupportedOperationException raised during "DFS query then fetch" with range query in rescorer

**URL:** <https://discuss.elastic.co/t/unsupportedoperationexception-raised-during-dfs-query-then-fetch-with-range-query-in-rescorer/20202>\
**Category:** Elasticsearch\
**Created:** [October 12, 2014, 12:21am UTC](https://discuss.elastic.co/t/unsupportedoperationexception-raised-during-dfs-query-then-fetch-with-range-query-in-rescorer/20202 "2014-10-12T00:21:07Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![g\_dhordain](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/g_dhordain/32/1216_2.png) [@g\_dhordain](https://discuss.elastic.co/u/g_dhordain)\
**Post date:** [October 12, 2014, 12:21am UTC](https://discuss.elastic.co/t/unsupportedoperationexception-raised-during-dfs-query-then-fetch-with-range-query-in-rescorer/20202/1 "2014-10-12T00:21:07Z")

</div>

Hi,

When I try to run a query with a range query rescorer, Elasticsearch  
(version 1.3.2) will raise an java.lang.UnsupportedOperationException  
on org.apache.lucene.search.Query.extractTerms. The exact class raising the  
exception was NumericRangeQuery in my test.

After some investigations, I found that this occurs when ES try to extract  
terms in each rescorer (source  
[https://github.com/elasticsearch/elasticsearch/blob/v1.3.2/src/main/java/org/elasticsearch/search/dfs/DfsPhase.java#L75](https://github.com/elasticsearch/elasticsearch/blob/v1.3.2/src/main/java/org/elasticsearch/search/dfs/DfsPhase.java#L75)).  
Everything is working fine for the search query as it is rewritten before  
the "extractTerms" method is called (source  
[https://github.com/elasticsearch/elasticsearch/blob/v1.3.2/src/main/java/org/elasticsearch/search/dfs/DfsPhase.java#L67](https://github.com/elasticsearch/elasticsearch/blob/v1.3.2/src/main/java/org/elasticsearch/search/dfs/DfsPhase.java#L67)  
).  
If I rewrite myself the query as ES would do, everything seems to work  
fine. This works because Lucene does not extract terms encapsulated in  
filter inside ConstantScoreQuery (source  
[https://github.com/apache/lucene-solr/blob/lucene\_solr\_4\_9\_0/lucene/core/src/java/org/apache/lucene/search/ConstantScoreQuery.java#L98-L103](https://github.com/apache/lucene-solr/blob/lucene_solr_4_9_0/lucene/core/src/java/org/apache/lucene/search/ConstantScoreQuery.java#L98-L103)  
).

You can find the curl recreation is this gist  
: [https://gist.github.com/Jdourd/de2ab3f1eb23fe7e06be](https://gist.github.com/Jdourd/de2ab3f1eb23fe7e06be)

Regards,  
Gautier

--  
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/86af99b8-84c4-4ef3-97fc-9eb2a3e996b2%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/86af99b8-84c4-4ef3-97fc-9eb2a3e996b2%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, 12:56am UTC](https://discuss.elastic.co/t/unsupportedoperationexception-raised-during-dfs-query-then-fetch-with-range-query-in-rescorer/20202/2 "2017-07-06T00:56:43Z")

</div>

Closed on July 6, 2017, 12:56am UTC


