# Termsstats / stats facets giving ClassCastException\[org.elasticsearch.index.fielddata.plain.PagedBytesIndexFieldData cannot be cast to org.elasticsearch.index.fielddata.IndexNumericFieldData\]

**URL:** <https://discuss.elastic.co/t/termsstats-stats-facets-giving-classcastexception-org-elasticsearch-index-fielddata-plain-pagedbytesindexfielddata-cannot-be-cast-to-org-elasticsearch-index-fielddata-indexnumericfielddata/11504>\
**Category:** Elasticsearch\
**Created:** [April 9, 2013, 12:56pm UTC](https://discuss.elastic.co/t/termsstats-stats-facets-giving-classcastexception-org-elasticsearch-index-fielddata-plain-pagedbytesindexfielddata-cannot-be-cast-to-org-elasticsearch-index-fielddata-indexnumericfielddata/11504 "2013-04-09T12:56:28Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Maaz\_Bin\_Tariq](https://avatars.discourse-cdn.com/v4/letter/m/ee7513/32.png) [@Maaz\_Bin\_Tariq](https://discuss.elastic.co/u/Maaz_Bin_Tariq)\
**Post date:** [April 9, 2013, 12:56pm UTC](https://discuss.elastic.co/t/termsstats-stats-facets-giving-classcastexception-org-elasticsearch-index-fielddata-plain-pagedbytesindexfielddata-cannot-be-cast-to-org-elasticsearch-index-fielddata-indexnumericfielddata/11504/1 "2013-04-09T12:56:28Z")

</div>

Hi,

I am using elasticsearch.0.90.0.RC1, and I am unable to use termstatsfacet  
and statistical-facet,

Do they require any specfic fields mappings?

_Using statistical-facet_  
{  
"query": {  
"match\_all": {}  
},  
"facets": {  
"campaign\_stats": {  
"statistical": {  
"field": "campaign\_id.id"  
}  
}  
}  
}

_Using termstatsfacet_  
{  
"query": {  
"match\_all" : { }  
},  
"facets": {  
"campaign\_stats": {  
"terms\_stats": {  
"key\_field": "campaign\_id.id",  
"value\_field": "amount.ll"  
}  
}  
}  
}

_Both gives the same exception_  
nested:  
ClassCastException[org.elasticsearch.index.fielddata.plain.PagedBytesIndexFieldData  
cannot be cast to org.elasticsearch.index.fielddata.IndexNumericFieldData];  
}]","status":500

What I need to do to make it work?

Thanks  
-Maaz

--  
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).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![simonw\_2](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/simonw_2/32/1130_2.png) [@simonw\_2](https://discuss.elastic.co/u/simonw_2)\
**Post date:** [April 9, 2013, 1:36pm UTC](https://discuss.elastic.co/t/termsstats-stats-facets-giving-classcastexception-org-elasticsearch-index-fielddata-plain-pagedbytesindexfielddata-cannot-be-cast-to-org-elasticsearch-index-fielddata-indexnumericfielddata/11504/2 "2013-04-09T13:36:02Z")

</div>

hey can you provide your mapping please and maybe the exception that is in  
the log files?

simon

On Tuesday, April 9, 2013 2:56:28 PM UTC+2, Maaz Bin Tariq wrote:

> Hi,
> 
> I am using elasticsearch.0.90.0.RC1, and I am unable to use termstatsfacet  
> and statistical-facet,
> 
> Do they require any specfic fields mappings?
> 
> _Using statistical-facet_  
> {  
> "query": {  
> "match\_all": {}  
> },  
> "facets": {  
> "campaign\_stats": {  
> "statistical": {  
> "field": "campaign\_id.id"  
> }  
> }  
> }  
> }
> 
> _Using termstatsfacet_  
> {  
> "query": {  
> "match\_all" : { }  
> },  
> "facets": {  
> "campaign\_stats": {  
> "terms\_stats": {  
> "key\_field": "campaign\_id.id",  
> "value\_field": "amount.ll"  
> }  
> }  
> }  
> }
> 
> _Both gives the same exception_  
> nested:  
> ClassCastException[org.elasticsearch.index.fielddata.plain.PagedBytesIndexFieldData  
> cannot be cast to org.elasticsearch.index.fielddata.IndexNumericFieldData];  
> }]","status":500
> 
> What I need to do to make it work?
> 
> Thanks  
> -Maaz

--  
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).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![Maaz\_Bin\_Tariq](https://avatars.discourse-cdn.com/v4/letter/m/ee7513/32.png) [@Maaz\_Bin\_Tariq](https://discuss.elastic.co/u/Maaz_Bin_Tariq)\
**Post date:** [April 10, 2013, 4:53am UTC](https://discuss.elastic.co/t/termsstats-stats-facets-giving-classcastexception-org-elasticsearch-index-fielddata-plain-pagedbytesindexfielddata-cannot-be-cast-to-org-elasticsearch-index-fielddata-indexnumericfielddata/11504/3 "2013-04-10T04:53:20Z")

</div>

_Mappings_

{  
"pledge": {  
"properties": {  
"amount": {  
"properties": {  
"ll": {  
"type": "long"  
}  
}  
},  
"campaign\_id": {  
"properties": {  
"id": {  
"type": "long"  
}  
}  
},  
"user": {  
"properties": {  
"id": {  
"type": "string"  
}  
}  
}  
}  
}  
}  
\*  
\*  
_Exception in log files_  
Parse Failure [Failed to parse source [{  
"query": {  
"match\_all": {}  
},  
"facets": {  
"campaign\_stats": {  
"statistical": {  
"field": "\_id"  
}  
}  
}  
}]]  
at  
org.elasticsearch.search.SearchService.parseSource(SearchService.java:566)  
at  
org.elasticsearch.search.SearchService.createContext(SearchService.java:481)  
at  
org.elasticsearch.search.SearchService.createContext(SearchService.java:466)  
at  
org.elasticsearch.search.SearchService.executeQueryPhase(SearchService.java:236)  
at  
org.elasticsearch.search.action.SearchServiceTransportAction.sendExecuteQuery(SearchServiceTransportAction.java:141)  
at  
org.elasticsearch.action.search.type.TransportSearchQueryThenFetchAction$AsyncAction.sendExecuteFirstPhase(TransportSearchQueryThenFetchAction.java:80)  
at  
org.elasticsearch.action.search.type.TransportSearchTypeAction$BaseAsyncAction.performFirstPhase(TransportSearchTypeAction.java:205)  
at  
org.elasticsearch.action.search.type.TransportSearchTypeAction$BaseAsyncAction.performFirstPhase(TransportSearchTypeAction.java:192)  
at  
org.elasticsearch.action.search.type.TransportSearchTypeAction$BaseAsyncAction$2.run(TransportSearchTypeAction.java:178)  
at  
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:885)  
at  
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:907)  
at java.lang.Thread.run(Thread.java:619)  
Caused by: java.lang.ClassCastException:  
org.elasticsearch.index.fielddata.plain.PagedBytesIndexFieldData cannot be  
cast to org.elasticsearch.index.fielddata.IndexNumericFieldData  
at  
org.elasticsearch.search.facet.statistical.StatisticalFacetParser.parse(StatisticalFacetParser.java:119)  
at  
org.elasticsearch.search.facet.FacetParseElement.parse(FacetParseElement.java:92)  
at  
org.elasticsearch.search.SearchService.parseSource(SearchService.java:554)  
... 11 more

On Tue, Apr 9, 2013 at 6:36 PM, simonw [simon.willnauer@elasticsearch.com](mailto:simon.willnauer@elasticsearch.com)wrote:

> hey can you provide your mapping please and maybe the exception that is in  
> the log files?
> 
> simon
> 
> On Tuesday, April 9, 2013 2:56:28 PM UTC+2, Maaz Bin Tariq wrote:
> 
> > Hi,
> > 
> > I am using elasticsearch.0.90.0.RC1, and I am unable to use  
> > termstatsfacet and statistical-facet,
> > 
> > Do they require any specfic fields mappings?
> > 
> > _Using statistical-facet_  
> > {  
> > "query": {  
> > "match\_all": {}  
> > },  
> > "facets": {  
> > "campaign\_stats": {  
> > "statistical": {  
> > "field": "campaign\_id.id"  
> > }  
> > }  
> > }  
> > }
> > 
> > _Using termstatsfacet_  
> > {  
> > "query": {  
> > "match\_all" : { }  
> > },  
> > "facets": {  
> > "campaign\_stats": {  
> > "terms\_stats": {  
> > "key\_field": "campaign\_id.id",  
> > "value\_field": "amount.ll"  
> > }  
> > }  
> > }  
> > }
> > 
> > _Both gives the same exception_  
> > nested: ClassCastException[org.\*\*elasticsearch.index.fielddata.\*\*plain.PagedBytesIndexFieldData  
> > cannot be cast to org.elasticsearch.index.\*\*fielddata.\*\*IndexNumericFieldData];  
> > }]","status":500
> > 
> > What I need to do to make it work?
> > 
> > Thanks  
> > -Maaz
> 
> --  
> You received this message because you are subscribed to a topic in the  
> Google Groups "elasticsearch" group.  
> To unsubscribe from this topic, visit  
> [https://groups.google.com/d/topic/elasticsearch/K7Z\_17U3im0/unsubscribe?hl=en-US](https://groups.google.com/d/topic/elasticsearch/K7Z_17U3im0/unsubscribe?hl=en-US)  
> .  
> To unsubscribe from this group and all its topics, send an email to  
> [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
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).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![mvg](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mvg/32/98890_2.png) [@mvg](https://discuss.elastic.co/u/mvg)\
**Post date:** [April 10, 2013, 8:56am UTC](https://discuss.elastic.co/t/termsstats-stats-facets-giving-classcastexception-org-elasticsearch-index-fielddata-plain-pagedbytesindexfielddata-cannot-be-cast-to-org-elasticsearch-index-fielddata-indexnumericfielddata/11504/4 "2013-04-10T08:56:28Z")

</div>

In the last stacktrace you shared, you are using the "\_id" field which is a  
string and not an number. The stats facet only works for number based  
fields (int, long, short etc). The error returned is't helpful and I will  
make the error more descriptive.

I also tested your search request examples from your first email and it  
those seem to work fine. Did you ran these search requests with the mapping  
you send in your latest email?

On 10 April 2013 06:53, Maaz Bin Tariq [maaz786@gmail.com](mailto:maaz786@gmail.com) wrote:

> _Mappings_
> 
> {  
> "pledge": {  
> "properties": {  
> "amount": {  
> "properties": {  
> "ll": {  
> "type": "long"  
> }  
> }  
> },  
> "campaign\_id": {  
> "properties": {  
> "id": {  
> "type": "long"  
> }  
> }  
> },  
> "user": {  
> "properties": {  
> "id": {  
> "type": "string"  
> }  
> }  
> }  
> }  
> }  
> }  
> \*  
> \*  
> _Exception in log files_  
> Parse Failure [Failed to parse source [{  
> "query": {  
> "match\_all": {}  
> },  
> "facets": {  
> "campaign\_stats": {  
> "statistical": {  
> "field": "\_id"  
> }  
> }  
> }  
> }]]  
> at  
> org.elasticsearch.search.SearchService.parseSource(SearchService.java:566)  
> at  
> org.elasticsearch.search.SearchService.createContext(SearchService.java:481)  
> at  
> org.elasticsearch.search.SearchService.createContext(SearchService.java:466)  
> at  
> org.elasticsearch.search.SearchService.executeQueryPhase(SearchService.java:236)  
> at  
> org.elasticsearch.search.action.SearchServiceTransportAction.sendExecuteQuery(SearchServiceTransportAction.java:141)  
> at  
> org.elasticsearch.action.search.type.TransportSearchQueryThenFetchAction$AsyncAction.sendExecuteFirstPhase(TransportSearchQueryThenFetchAction.java:80)  
> at  
> org.elasticsearch.action.search.type.TransportSearchTypeAction$BaseAsyncAction.performFirstPhase(TransportSearchTypeAction.java:205)  
> at  
> org.elasticsearch.action.search.type.TransportSearchTypeAction$BaseAsyncAction.performFirstPhase(TransportSearchTypeAction.java:192)  
> at  
> org.elasticsearch.action.search.type.TransportSearchTypeAction$BaseAsyncAction$2.run(TransportSearchTypeAction.java:178)  
> at  
> java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:885)  
> at  
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:907)  
> at java.lang.Thread.run(Thread.java:619)  
> Caused by: java.lang.ClassCastException:  
> org.elasticsearch.index.fielddata.plain.PagedBytesIndexFieldData cannot be  
> cast to org.elasticsearch.index.fielddata.IndexNumericFieldData  
> at  
> org.elasticsearch.search.facet.statistical.StatisticalFacetParser.parse(StatisticalFacetParser.java:119)  
> at  
> org.elasticsearch.search.facet.FacetParseElement.parse(FacetParseElement.java:92)  
> at  
> org.elasticsearch.search.SearchService.parseSource(SearchService.java:554)  
> ... 11 more
> 
> On Tue, Apr 9, 2013 at 6:36 PM, simonw [simon.willnauer@elasticsearch.com](mailto:simon.willnauer@elasticsearch.com)wrote:
> 
> > hey can you provide your mapping please and maybe the exception that is  
> > in the log files?
> > 
> > simon
> > 
> > On Tuesday, April 9, 2013 2:56:28 PM UTC+2, Maaz Bin Tariq wrote:
> > 
> > > Hi,
> > > 
> > > I am using elasticsearch.0.90.0.RC1, and I am unable to use  
> > > termstatsfacet and statistical-facet,
> > > 
> > > Do they require any specfic fields mappings?
> > > 
> > > _Using statistical-facet_  
> > > {  
> > > "query": {  
> > > "match\_all": {}  
> > > },  
> > > "facets": {  
> > > "campaign\_stats": {  
> > > "statistical": {  
> > > "field": "campaign\_id.id"  
> > > }  
> > > }  
> > > }  
> > > }
> > > 
> > > _Using termstatsfacet_  
> > > {  
> > > "query": {  
> > > "match\_all" : { }  
> > > },  
> > > "facets": {  
> > > "campaign\_stats": {  
> > > "terms\_stats": {  
> > > "key\_field": "campaign\_id.id",  
> > > "value\_field": "amount.ll"  
> > > }  
> > > }  
> > > }  
> > > }
> > > 
> > > _Both gives the same exception_  
> > > nested: ClassCastException[org.\*\*elasticsearch.index.fielddata.\*\*plain.PagedBytesIndexFieldData  
> > > cannot be cast to org.elasticsearch.index.\*\*fielddata.\*\*IndexNumericFieldData];  
> > > }]","status":500
> > > 
> > > What I need to do to make it work?
> > > 
> > > Thanks  
> > > -Maaz
> > 
> > --  
> > You received this message because you are subscribed to a topic in the  
> > Google Groups "elasticsearch" group.  
> > To unsubscribe from this topic, visit  
> > [https://groups.google.com/d/topic/elasticsearch/K7Z\_17U3im0/unsubscribe?hl=en-US](https://groups.google.com/d/topic/elasticsearch/K7Z_17U3im0/unsubscribe?hl=en-US)  
> > .  
> > To unsubscribe from this group and all its topics, send an email to  
> > [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).
> > 
> > For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).
> 
> --  
> 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).  
> For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
Met vriendelijke groet,

Martijn van Groningen

--  
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).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![Maaz\_Bin\_Tariq](https://avatars.discourse-cdn.com/v4/letter/m/ee7513/32.png) [@Maaz\_Bin\_Tariq](https://discuss.elastic.co/u/Maaz_Bin_Tariq)\
**Post date:** [April 10, 2013, 11:01am UTC](https://discuss.elastic.co/t/termsstats-stats-facets-giving-classcastexception-org-elasticsearch-index-fielddata-plain-pagedbytesindexfielddata-cannot-be-cast-to-org-elasticsearch-index-fielddata-indexnumericfielddata/11504/5 "2013-04-10T11:01:47Z")

</div>

Yup, I also try to use \_id field , other facets error are below, I use the  
same mappings,  
I have now moved to 0.90.0.RC2 the problem seems to go away.

_Other Exceptions are_  
Parse Failure [Failed to parse source [{  
"query": {  
"match\_all": {}  
},  
"facets": {  
"campaign\_stats": {  
"statistical": {  
"field": "campaign\_id.id"  
}  
}  
}  
}]]  
at  
org.elasticsearch.search.SearchService.parseSource(SearchService.java:566)  
at  
org.elasticsearch.search.SearchService.createContext(SearchService.java:481)  
at  
org.elasticsearch.search.SearchService.createContext(SearchService.java:466)  
at  
org.elasticsearch.search.SearchService.executeQueryPhase(SearchService.java:236)  
at  
org.elasticsearch.search.action.SearchServiceTransportAction.sendExecuteQuery(SearchServiceTransportAction.java:141)  
at  
org.elasticsearch.action.search.type.TransportSearchQueryThenFetchAction$AsyncAction.sendExecuteFirstPhase(TransportSearchQueryThenFetchAction.java:80)  
at  
org.elasticsearch.action.search.type.TransportSearchTypeAction$BaseAsyncAction.performFirstPhase(TransportSearchTypeAction.java:205)  
at  
org.elasticsearch.action.search.type.TransportSearchTypeAction$BaseAsyncAction.performFirstPhase(TransportSearchTypeAction.java:192)  
at  
org.elasticsearch.action.search.type.TransportSearchTypeAction$BaseAsyncAction$2.run(TransportSearchTypeAction.java:178)  
at  
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:885)  
at  
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:907)  
at java.lang.Thread.run(Thread.java:619)  
Caused by: java.lang.ClassCastException:  
org.elasticsearch.index.fielddata.plain.PagedBytesIndexFieldData cannot be  
cast to org.elasticsearch.index.fielddata.IndexNumericFieldData  
at  
org.elasticsearch.search.facet.statistical.StatisticalFacetParser.parse(StatisticalFacetParser.java:119)  
at  
org.elasticsearch.search.facet.FacetParseElement.parse(FacetParseElement.java:92)  
at  
org.elasticsearch.search.SearchService.parseSource(SearchService.java:554)  
... 11 more

* * *

Parse Failure [Failed to parse source [{  
"query": {  
"match\_all" : { }  
},  
"facets": {  
"campaign\_stats": {  
"terms\_stats": {  
"key\_field": "campaign\_id.id",  
"value\_field": "amount.ll"  
}  
}  
}  
}]]  
at  
org.elasticsearch.search.SearchService.parseSource(SearchService.java:566)  
at  
org.elasticsearch.search.SearchService.createContext(SearchService.java:481)  
at  
org.elasticsearch.search.SearchService.createContext(SearchService.java:466)  
at  
org.elasticsearch.search.SearchService.executeQueryPhase(SearchService.java:236)  
at  
org.elasticsearch.search.action.SearchServiceTransportAction.sendExecuteQuery(SearchServiceTransportAction.java:141)  
at  
org.elasticsearch.action.search.type.TransportSearchQueryThenFetchAction$AsyncAction.sendExecuteFirstPhase(TransportSearchQueryThenFetchAction.java:80)  
at  
org.elasticsearch.action.search.type.TransportSearchTypeAction$BaseAsyncAction.performFirstPhase(TransportSearchTypeAction.java:205)  
at  
org.elasticsearch.action.search.type.TransportSearchTypeAction$BaseAsyncAction.performFirstPhase(TransportSearchTypeAction.java:192)  
at  
org.elasticsearch.action.search.type.TransportSearchTypeAction$BaseAsyncAction$2.run(TransportSearchTypeAction.java:178)  
at  
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:885)  
at  
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:907)  
at java.lang.Thread.run(Thread.java:619)  
Caused by: java.lang.ClassCastException:  
org.elasticsearch.index.fielddata.plain.PagedBytesIndexFieldData cannot be  
cast to org.elasticsearch.index.fielddata.IndexNumericFieldData  
at  
org.elasticsearch.search.facet.termsstats.TermsStatsFacetParser.parse(TermsStatsFacetParser.java:124)  
at  
org.elasticsearch.search.facet.FacetParseElement.parse(FacetParseElement.java:92)  
at  
org.elasticsearch.search.SearchService.parseSource(SearchService.java:554)  
... 11 more

On Wed, Apr 10, 2013 at 1:56 PM, Martijn v Groningen \<  
[martijn.v.groningen@gmail.com](mailto:martijn.v.groningen@gmail.com)\> wrote:

> In the last stacktrace you shared, you are using the "\_id" field which is  
> a string and not an number. The stats facet only works for number based  
> fields (int, long, short etc). The error returned is't helpful and I will  
> make the error more descriptive.
> 
> I also tested your search request examples from your first email and it  
> those seem to work fine. Did you ran these search requests with the mapping  
> you send in your latest email?
> 
> On 10 April 2013 06:53, Maaz Bin Tariq [maaz786@gmail.com](mailto:maaz786@gmail.com) wrote:
> 
> > _Mappings_
> > 
> > {  
> > "pledge": {  
> > "properties": {  
> > "amount": {  
> > "properties": {  
> > "ll": {  
> > "type": "long"  
> > }  
> > }  
> > },  
> > "campaign\_id": {  
> > "properties": {  
> > "id": {  
> > "type": "long"  
> > }  
> > }  
> > },  
> > "user": {  
> > "properties": {  
> > "id": {  
> > "type": "string"  
> > }  
> > }  
> > }  
> > }  
> > }  
> > }  
> > \*  
> > \*  
> > _Exception in log files_  
> > Parse Failure [Failed to parse source [{  
> > "query": {  
> > "match\_all": {}  
> > },  
> > "facets": {  
> > "campaign\_stats": {  
> > "statistical": {  
> > "field": "\_id"  
> > }  
> > }  
> > }  
> > }]]  
> > at  
> > org.elasticsearch.search.SearchService.parseSource(SearchService.java:566)  
> > at  
> > org.elasticsearch.search.SearchService.createContext(SearchService.java:481)  
> > at  
> > org.elasticsearch.search.SearchService.createContext(SearchService.java:466)  
> > at  
> > org.elasticsearch.search.SearchService.executeQueryPhase(SearchService.java:236)  
> > at  
> > org.elasticsearch.search.action.SearchServiceTransportAction.sendExecuteQuery(SearchServiceTransportAction.java:141)  
> > at  
> > org.elasticsearch.action.search.type.TransportSearchQueryThenFetchAction$AsyncAction.sendExecuteFirstPhase(TransportSearchQueryThenFetchAction.java:80)  
> > at  
> > org.elasticsearch.action.search.type.TransportSearchTypeAction$BaseAsyncAction.performFirstPhase(TransportSearchTypeAction.java:205)  
> > at  
> > org.elasticsearch.action.search.type.TransportSearchTypeAction$BaseAsyncAction.performFirstPhase(TransportSearchTypeAction.java:192)  
> > at  
> > org.elasticsearch.action.search.type.TransportSearchTypeAction$BaseAsyncAction$2.run(TransportSearchTypeAction.java:178)  
> > at  
> > java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:885)  
> > at  
> > java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:907)  
> > at java.lang.Thread.run(Thread.java:619)  
> > Caused by: java.lang.ClassCastException:  
> > org.elasticsearch.index.fielddata.plain.PagedBytesIndexFieldData cannot be  
> > cast to org.elasticsearch.index.fielddata.IndexNumericFieldData  
> > at  
> > org.elasticsearch.search.facet.statistical.StatisticalFacetParser.parse(StatisticalFacetParser.java:119)  
> > at  
> > org.elasticsearch.search.facet.FacetParseElement.parse(FacetParseElement.java:92)  
> > at  
> > org.elasticsearch.search.SearchService.parseSource(SearchService.java:554)  
> > ... 11 more
> > 
> > On Tue, Apr 9, 2013 at 6:36 PM, simonw \<[simon.willnauer@elasticsearch.com](mailto:simon.willnauer@elasticsearch.com)
> > 
> > > wrote:
> > 
> > > hey can you provide your mapping please and maybe the exception that is  
> > > in the log files?
> > > 
> > > simon
> > > 
> > > On Tuesday, April 9, 2013 2:56:28 PM UTC+2, Maaz Bin Tariq wrote:
> > > 
> > > > Hi,
> > > > 
> > > > I am using elasticsearch.0.90.0.RC1, and I am unable to use  
> > > > termstatsfacet and statistical-facet,
> > > > 
> > > > Do they require any specfic fields mappings?
> > > > 
> > > > _Using statistical-facet_  
> > > > {  
> > > > "query": {  
> > > > "match\_all": {}  
> > > > },  
> > > > "facets": {  
> > > > "campaign\_stats": {  
> > > > "statistical": {  
> > > > "field": "campaign\_id.id"  
> > > > }  
> > > > }  
> > > > }  
> > > > }
> > > > 
> > > > _Using termstatsfacet_  
> > > > {  
> > > > "query": {  
> > > > "match\_all" : { }  
> > > > },  
> > > > "facets": {  
> > > > "campaign\_stats": {  
> > > > "terms\_stats": {  
> > > > "key\_field": "campaign\_id.id",  
> > > > "value\_field": "amount.ll"  
> > > > }  
> > > > }  
> > > > }  
> > > > }
> > > > 
> > > > _Both gives the same exception_  
> > > > nested: ClassCastException[org.\*\*elasticsearch.index.fielddata.\*\*plain.PagedBytesIndexFieldData  
> > > > cannot be cast to org.elasticsearch.index.\*\*fielddata.\*\*IndexNumericFieldData];  
> > > > }]","status":500
> > > > 
> > > > What I need to do to make it work?
> > > > 
> > > > Thanks  
> > > > -Maaz
> > > 
> > > --  
> > > You received this message because you are subscribed to a topic in the  
> > > Google Groups "elasticsearch" group.  
> > > To unsubscribe from this topic, visit  
> > > [https://groups.google.com/d/topic/elasticsearch/K7Z\_17U3im0/unsubscribe?hl=en-US](https://groups.google.com/d/topic/elasticsearch/K7Z_17U3im0/unsubscribe?hl=en-US)  
> > > .  
> > > To unsubscribe from this group and all its topics, send an email to  
> > > [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).
> > > 
> > > For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).
> > 
> > --  
> > 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).
> > 
> > For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).
> 
> --  
> Met vriendelijke groet,
> 
> Martijn van Groningen
> 
> --  
> You received this message because you are subscribed to a topic in the  
> Google Groups "elasticsearch" group.  
> To unsubscribe from this topic, visit  
> [https://groups.google.com/d/topic/elasticsearch/K7Z\_17U3im0/unsubscribe?hl=en-US](https://groups.google.com/d/topic/elasticsearch/K7Z_17U3im0/unsubscribe?hl=en-US)  
> .  
> To unsubscribe from this group and all its topics, send an email to  
> [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
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).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<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, 2:41am UTC](https://discuss.elastic.co/t/termsstats-stats-facets-giving-classcastexception-org-elasticsearch-index-fielddata-plain-pagedbytesindexfielddata-cannot-be-cast-to-org-elasticsearch-index-fielddata-indexnumericfielddata/11504/6 "2017-07-06T02:41:50Z")

</div>


