# Failed to add StatisticalFacet on a integer type field ( NumberFormatException: Invalid shift value in prefixCoded string (is encoded value really an INT?) )

**URL:** <https://discuss.elastic.co/t/failed-to-add-statisticalfacet-on-a-integer-type-field-numberformatexception-invalid-shift-value-in-prefixcoded-string-is-encoded-value-really-an-int/9875>\
**Category:** Elasticsearch\
**Created:** [November 29, 2012, 6:56am UTC](https://discuss.elastic.co/t/failed-to-add-statisticalfacet-on-a-integer-type-field-numberformatexception-invalid-shift-value-in-prefixcoded-string-is-encoded-value-really-an-int/9875 "2012-11-29T06:56:17Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Barak\_Yaish](https://avatars.discourse-cdn.com/v4/letter/b/9de053/32.png) [@Barak\_Yaish](https://discuss.elastic.co/u/Barak_Yaish)\
**Post date:** [November 29, 2012, 6:56am UTC](https://discuss.elastic.co/t/failed-to-add-statisticalfacet-on-a-integer-type-field-numberformatexception-invalid-shift-value-in-prefixcoded-string-is-encoded-value-really-an-int/9875/1 "2012-11-29T06:56:17Z")

</div>

Hi,

I’ve added the following mapping:

{"user":{"properties":{"name":{"type":"string","store":"yes"},"visits":{"type":"integer","store":"yes"},"comments":{"type":"string","store":"yes"}}}}

And indexing few documents.

Using the java API, I want to add facet FacetBuilders.statisticalFacet(  
"facet" ).field( “visits” ), but exception is raised:

[2012-11-29 08:25:34,570][DEBUG][action.search.type] [Rose] [user][0],  
node[pkseu6UeSd-cYlT9kA3bWw], [P], s[STARTED]: Failed to execute  
[org.elasticsearch.action.search.SearchRequest@62edc88b]

org.elasticsearch.search.query.QueryPhaseExecutionException: [user][0]:  
query[name:"Igor"],from[0],size[10000000]: Query Failed [Failed to execute  
main query]  
at org.elasticsearch.search.query.QueryPhase.execute(QueryPhase.java:198)  
at  
org.elasticsearch.search.SearchService.executeQueryPhase(SearchService.java:234)

at  
org.elasticsearch.search.action.SearchServiceTransportAction.sendExecuteQuery(SearchServiceTransportAction.java:140)

at  
org.elasticsearch.action.search.type.TransportSearchQueryThenFetchAction$AsyncAction.sendExecuteFirstPhase(TransportSearchQueryThenFetchAction.java:80)

at  
org.elasticsearch.action.search.type.TransportSearchTypeAction$BaseAsyncAction.performFirstPhase(TransportSearchTypeAction.java:204)

at  
org.elasticsearch.action.search.type.TransportSearchTypeAction$BaseAsyncAction.performFirstPhase(TransportSearchTypeAction.java:191)

at  
org.elasticsearch.action.search.type.TransportSearchTypeAction$BaseAsyncAction$2.run(TransportSearchTypeAction.java:177)

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:619)

Caused by: java.lang.NumberFormatException: Invalid shift value in  
prefixCoded string (is encoded value really an INT?)

at  
org.apache.lucene.util.NumericUtils.prefixCodedToInt(NumericUtils.java:232)  
at org.apache.lucene.search.FieldCache$7.parseInt(FieldCache.java:243)  
at  
org.elasticsearch.index.field.data.ints.IntFieldData$IntTypeLoader.collectTerm(IntFieldData.java:150)

at  
org.elasticsearch.index.field.data.support.FieldDataLoader.load(FieldDataLoader.java:55)

at  
org.elasticsearch.index.field.data.ints.IntFieldData.load(IntFieldData.java:135)

at  
org.elasticsearch.index.field.data.ints.IntFieldDataType.load(IntFieldDataType.java:91)

at  
org.elasticsearch.index.field.data.ints.IntFieldDataType.load(IntFieldDataType.java:33)

at org.elasticsearch.index.field.data.FieldData.load(FieldData.java:111)  
at  
org.elasticsearch.index.cache.field.data.support.AbstractConcurrentMapFieldDataCache.cache(AbstractConcurrentMapFieldDataCache.java:123)

at  
org.elasticsearch.search.facet.statistical.StatisticalFacetCollector.doSetNextReader(StatisticalFacetCollector.java:74)

at  
org.elasticsearch.search.facet.AbstractFacetCollector.setNextReader(AbstractFacetCollector.java:75)

at  
org.elasticsearch.common.lucene.MultiCollector.setNextReader(MultiCollector.java:67)

at org.apache.lucene.search.IndexSearcher.search(IndexSearcher.java:576)  
at  
org.elasticsearch.search.internal.ContextIndexSearcher.search(ContextIndexSearcher.java:195)

at org.apache.lucene.search.IndexSearcher.search(IndexSearcher.java:445)  
at org.apache.lucene.search.IndexSearcher.search(IndexSearcher.java:426)  
at org.apache.lucene.search.IndexSearcher.search(IndexSearcher.java:342)  
at org.apache.lucene.search.IndexSearcher.search(IndexSearcher.java:330)  
at org.elasticsearch.search.query.QueryPhase.execute(QueryPhase.java:194)  
... 9 more

Did I do something wrong in the mapping? When I run searches without the  
facet, SearchHit. sourceAsMap().get( "visits" ) gets this field as Integer.

Thanks.

--

---

<div class="post-metadata">

**Author:** ![Igor\_Motov](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/igor_motov/32/45193_2.png) [@Igor\_Motov](https://discuss.elastic.co/u/Igor_Motov)\
**Post date:** [November 29, 2012, 12:16pm UTC](https://discuss.elastic.co/t/failed-to-add-statisticalfacet-on-a-integer-type-field-numberformatexception-invalid-shift-value-in-prefixcoded-string-is-encoded-value-really-an-int/9875/2 "2012-11-29T12:16:38Z")

</div>

Could it be this issue  
[https://groups.google.com/d/topic/elasticsearch/PJ8V6LmYZRo/discussion](https://groups.google.com/d/topic/elasticsearch/PJ8V6LmYZRo/discussion) ?

On Thursday, November 29, 2012 1:56:17 AM UTC-5, barak wrote:

> Hi,
> 
> I’ve added the following mapping:
> 
> {"user":{"properties":{"name":{"type":"string","store":"yes"},"visits":{"type":"integer","store":"yes"},"comments":{"type":"string","store":"yes"}}}}
> 
> And indexing few documents.
> 
> Using the java API, I want to add facet FacetBuilders.statisticalFacet(  
> "facet" ).field( “visits” ), but exception is raised:
> 
> [2012-11-29 08:25:34,570][DEBUG][action.search.type] [Rose] [user][0],  
> node[pkseu6UeSd-cYlT9kA3bWw], [P], s[STARTED]: Failed to execute  
> [org.elasticsearch.action.search.SearchRequest@62edc88b]
> 
> org.elasticsearch.search.query.QueryPhaseExecutionException: [user][0]:  
> query[name:"Igor"],from[0],size[10000000]: Query Failed [Failed to execute  
> main query]  
> at org.elasticsearch.search.query.QueryPhase.execute(QueryPhase.java:198)  
> at  
> org.elasticsearch.search.SearchService.executeQueryPhase(SearchService.java:234)
> 
> at  
> org.elasticsearch.search.action.SearchServiceTransportAction.sendExecuteQuery(SearchServiceTransportAction.java:140)
> 
> at  
> org.elasticsearch.action.search.type.TransportSearchQueryThenFetchAction$AsyncAction.sendExecuteFirstPhase(TransportSearchQueryThenFetchAction.java:80)
> 
> at  
> org.elasticsearch.action.search.type.TransportSearchTypeAction$BaseAsyncAction.performFirstPhase(TransportSearchTypeAction.java:204)
> 
> at  
> org.elasticsearch.action.search.type.TransportSearchTypeAction$BaseAsyncAction.performFirstPhase(TransportSearchTypeAction.java:191)
> 
> at  
> org.elasticsearch.action.search.type.TransportSearchTypeAction$BaseAsyncAction$2.run(TransportSearchTypeAction.java:177)
> 
> 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:619)
> 
> Caused by: java.lang.NumberFormatException: Invalid shift value in  
> prefixCoded string (is encoded value really an INT?)
> 
> at  
> org.apache.lucene.util.NumericUtils.prefixCodedToInt(NumericUtils.java:232)  
> at org.apache.lucene.search.FieldCache$7.parseInt(FieldCache.java:243)  
> at  
> org.elasticsearch.index.field.data.ints.IntFieldData$IntTypeLoader.collectTerm(IntFieldData.java:150)
> 
> at  
> org.elasticsearch.index.field.data.support.FieldDataLoader.load(FieldDataLoader.java:55)
> 
> at  
> org.elasticsearch.index.field.data.ints.IntFieldData.load(IntFieldData.java:135)
> 
> at  
> org.elasticsearch.index.field.data.ints.IntFieldDataType.load(IntFieldDataType.java:91)
> 
> at  
> org.elasticsearch.index.field.data.ints.IntFieldDataType.load(IntFieldDataType.java:33)
> 
> at org.elasticsearch.index.field.data.FieldData.load(FieldData.java:111)  
> at  
> org.elasticsearch.index.cache.field.data.support.AbstractConcurrentMapFieldDataCache.cache(AbstractConcurrentMapFieldDataCache.java:123)
> 
> at  
> org.elasticsearch.search.facet.statistical.StatisticalFacetCollector.doSetNextReader(StatisticalFacetCollector.java:74)
> 
> at  
> org.elasticsearch.search.facet.AbstractFacetCollector.setNextReader(AbstractFacetCollector.java:75)
> 
> at  
> org.elasticsearch.common.lucene.MultiCollector.setNextReader(MultiCollector.java:67)
> 
> at org.apache.lucene.search.IndexSearcher.search(IndexSearcher.java:576)  
> at  
> org.elasticsearch.search.internal.ContextIndexSearcher.search(ContextIndexSearcher.java:195)
> 
> at org.apache.lucene.search.IndexSearcher.search(IndexSearcher.java:445)  
> at org.apache.lucene.search.IndexSearcher.search(IndexSearcher.java:426)  
> at org.apache.lucene.search.IndexSearcher.search(IndexSearcher.java:342)  
> at org.apache.lucene.search.IndexSearcher.search(IndexSearcher.java:330)  
> at org.elasticsearch.search.query.QueryPhase.execute(QueryPhase.java:194)  
> ... 9 more
> 
> Did I do something wrong in the mapping? When I run searches without the  
> facet, SearchHit. sourceAsMap().get( "visits" ) gets this field as Integer.
> 
> Thanks.

--

---

<div class="post-metadata">

**Author:** ![Damien\_Alexandre](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/damien_alexandre/32/21566_2.png) [@Damien\_Alexandre](https://discuss.elastic.co/u/Damien_Alexandre)\
**Post date:** [April 19, 2013, 3:15pm UTC](https://discuss.elastic.co/t/failed-to-add-statisticalfacet-on-a-integer-type-field-numberformatexception-invalid-shift-value-in-prefixcoded-string-is-encoded-value-really-an-int/9875/3 "2013-04-19T15:15:51Z")

</div>

Hi Barak,

I know this is an old question but Google got me here and you seems to have  
the exact same issue as me,  
did you remember any solution?

Thx!

On Thursday, November 29, 2012 7:56:17 AM UTC+1, barak wrote:

> Hi,
> 
> I’ve added the following mapping:
> 
> {"user":{"properties":{"name":{"type":"string","store":"yes"},"visits":{"type":"integer","store":"yes"},"comments":{"type":"string","store":"yes"}}}}
> 
> And indexing few documents.
> 
> Using the java API, I want to add facet FacetBuilders.statisticalFacet(  
> "facet" ).field( “visits” ), but exception is raised:
> 
> [2012-11-29 08:25:34,570][DEBUG][action.search.type] [Rose] [user][0],  
> node[pkseu6UeSd-cYlT9kA3bWw], [P], s[STARTED]: Failed to execute  
> [org.elasticsearch.action.search.SearchRequest@62edc88b]
> 
> org.elasticsearch.search.query.QueryPhaseExecutionException: [user][0]:  
> query[name:"Igor"],from[0],size[10000000]: Query Failed [Failed to execute  
> main query]  
> at org.elasticsearch.search.query.QueryPhase.execute(QueryPhase.java:198)  
> at  
> org.elasticsearch.search.SearchService.executeQueryPhase(SearchService.java:234)
> 
> at  
> org.elasticsearch.search.action.SearchServiceTransportAction.sendExecuteQuery(SearchServiceTransportAction.java:140)
> 
> at  
> org.elasticsearch.action.search.type.TransportSearchQueryThenFetchAction$AsyncAction.sendExecuteFirstPhase(TransportSearchQueryThenFetchAction.java:80)
> 
> at  
> org.elasticsearch.action.search.type.TransportSearchTypeAction$BaseAsyncAction.performFirstPhase(TransportSearchTypeAction.java:204)
> 
> at  
> org.elasticsearch.action.search.type.TransportSearchTypeAction$BaseAsyncAction.performFirstPhase(TransportSearchTypeAction.java:191)
> 
> at  
> org.elasticsearch.action.search.type.TransportSearchTypeAction$BaseAsyncAction$2.run(TransportSearchTypeAction.java:177)
> 
> 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:619)
> 
> Caused by: java.lang.NumberFormatException: Invalid shift value in  
> prefixCoded string (is encoded value really an INT?)
> 
> at  
> org.apache.lucene.util.NumericUtils.prefixCodedToInt(NumericUtils.java:232)  
> at org.apache.lucene.search.FieldCache$7.parseInt(FieldCache.java:243)  
> at  
> org.elasticsearch.index.field.data.ints.IntFieldData$IntTypeLoader.collectTerm(IntFieldData.java:150)
> 
> at  
> org.elasticsearch.index.field.data.support.FieldDataLoader.load(FieldDataLoader.java:55)
> 
> at  
> org.elasticsearch.index.field.data.ints.IntFieldData.load(IntFieldData.java:135)
> 
> at  
> org.elasticsearch.index.field.data.ints.IntFieldDataType.load(IntFieldDataType.java:91)
> 
> at  
> org.elasticsearch.index.field.data.ints.IntFieldDataType.load(IntFieldDataType.java:33)
> 
> at org.elasticsearch.index.field.data.FieldData.load(FieldData.java:111)  
> at  
> org.elasticsearch.index.cache.field.data.support.AbstractConcurrentMapFieldDataCache.cache(AbstractConcurrentMapFieldDataCache.java:123)
> 
> at  
> org.elasticsearch.search.facet.statistical.StatisticalFacetCollector.doSetNextReader(StatisticalFacetCollector.java:74)
> 
> at  
> org.elasticsearch.search.facet.AbstractFacetCollector.setNextReader(AbstractFacetCollector.java:75)
> 
> at  
> org.elasticsearch.common.lucene.MultiCollector.setNextReader(MultiCollector.java:67)
> 
> at org.apache.lucene.search.IndexSearcher.search(IndexSearcher.java:576)  
> at  
> org.elasticsearch.search.internal.ContextIndexSearcher.search(ContextIndexSearcher.java:195)
> 
> at org.apache.lucene.search.IndexSearcher.search(IndexSearcher.java:445)  
> at org.apache.lucene.search.IndexSearcher.search(IndexSearcher.java:426)  
> at org.apache.lucene.search.IndexSearcher.search(IndexSearcher.java:342)  
> at org.apache.lucene.search.IndexSearcher.search(IndexSearcher.java:330)  
> at org.elasticsearch.search.query.QueryPhase.execute(QueryPhase.java:194)  
> ... 9 more
> 
> Did I do something wrong in the mapping? When I run searches without the  
> facet, SearchHit. sourceAsMap().get( "visits" ) gets this field as Integer.
> 
> Thanks.

--  
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:** ![Igor\_Motov](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/igor_motov/32/45193_2.png) [@Igor\_Motov](https://discuss.elastic.co/u/Igor_Motov)\
**Post date:** [April 19, 2013, 3:27pm UTC](https://discuss.elastic.co/t/failed-to-add-statisticalfacet-on-a-integer-type-field-numberformatexception-invalid-shift-value-in-prefixcoded-string-is-encoded-value-really-an-int/9875/4 "2013-04-19T15:27:43Z")

</div>

Did you try this solution?  
[https://groups.google.com/d/topic/elasticsearch/PJ8V6LmYZRo/discussion](https://groups.google.com/d/topic/elasticsearch/PJ8V6LmYZRo/discussion)

On Friday, April 19, 2013 11:15:51 AM UTC-4, Damien Alexandre wrote:

> Hi Barak,
> 
> I know this is an old question but Google got me here and you seems to  
> have the exact same issue as me,  
> did you remember any solution?
> 
> Thx!
> 
> On Thursday, November 29, 2012 7:56:17 AM UTC+1, barak wrote:
> 
> > Hi,
> > 
> > I’ve added the following mapping:
> > 
> > {"user":{"properties":{"name":{"type":"string","store":"yes"},"visits":{"type":"integer","store":"yes"},"comments":{"type":"string","store":"yes"}}}}
> > 
> > And indexing few documents.
> > 
> > Using the java API, I want to add facet FacetBuilders.statisticalFacet(  
> > "facet" ).field( “visits” ), but exception is raised:
> > 
> > [2012-11-29 08:25:34,570][DEBUG][action.search.type] [Rose] [user][0],  
> > node[pkseu6UeSd-cYlT9kA3bWw], [P], s[STARTED]: Failed to execute  
> > [org.elasticsearch.action.search.SearchRequest@62edc88b]
> > 
> > org.elasticsearch.search.query.QueryPhaseExecutionException: [user][0]:  
> > query[name:"Igor"],from[0],size[10000000]: Query Failed [Failed to execute  
> > main query]  
> > at org.elasticsearch.search.query.QueryPhase.execute(QueryPhase.java:198)  
> > at  
> > org.elasticsearch.search.SearchService.executeQueryPhase(SearchService.java:234)
> > 
> > at  
> > org.elasticsearch.search.action.SearchServiceTransportAction.sendExecuteQuery(SearchServiceTransportAction.java:140)
> > 
> > at  
> > org.elasticsearch.action.search.type.TransportSearchQueryThenFetchAction$AsyncAction.sendExecuteFirstPhase(TransportSearchQueryThenFetchAction.java:80)
> > 
> > at  
> > org.elasticsearch.action.search.type.TransportSearchTypeAction$BaseAsyncAction.performFirstPhase(TransportSearchTypeAction.java:204)
> > 
> > at  
> > org.elasticsearch.action.search.type.TransportSearchTypeAction$BaseAsyncAction.performFirstPhase(TransportSearchTypeAction.java:191)
> > 
> > at  
> > org.elasticsearch.action.search.type.TransportSearchTypeAction$BaseAsyncAction$2.run(TransportSearchTypeAction.java:177)
> > 
> > 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:619)
> > 
> > Caused by: java.lang.NumberFormatException: Invalid shift value in  
> > prefixCoded string (is encoded value really an INT?)
> > 
> > at  
> > org.apache.lucene.util.NumericUtils.prefixCodedToInt(NumericUtils.java:232)  
> > at org.apache.lucene.search.FieldCache$7.parseInt(FieldCache.java:243)  
> > at  
> > org.elasticsearch.index.field.data.ints.IntFieldData$IntTypeLoader.collectTerm(IntFieldData.java:150)
> > 
> > at  
> > org.elasticsearch.index.field.data.support.FieldDataLoader.load(FieldDataLoader.java:55)
> > 
> > at  
> > org.elasticsearch.index.field.data.ints.IntFieldData.load(IntFieldData.java:135)
> > 
> > at  
> > org.elasticsearch.index.field.data.ints.IntFieldDataType.load(IntFieldDataType.java:91)
> > 
> > at  
> > org.elasticsearch.index.field.data.ints.IntFieldDataType.load(IntFieldDataType.java:33)
> > 
> > at org.elasticsearch.index.field.data.FieldData.load(FieldData.java:111)  
> > at  
> > org.elasticsearch.index.cache.field.data.support.AbstractConcurrentMapFieldDataCache.cache(AbstractConcurrentMapFieldDataCache.java:123)
> > 
> > at  
> > org.elasticsearch.search.facet.statistical.StatisticalFacetCollector.doSetNextReader(StatisticalFacetCollector.java:74)
> > 
> > at  
> > org.elasticsearch.search.facet.AbstractFacetCollector.setNextReader(AbstractFacetCollector.java:75)
> > 
> > at  
> > org.elasticsearch.common.lucene.MultiCollector.setNextReader(MultiCollector.java:67)
> > 
> > at org.apache.lucene.search.IndexSearcher.search(IndexSearcher.java:576)  
> > at  
> > org.elasticsearch.search.internal.ContextIndexSearcher.search(ContextIndexSearcher.java:195)
> > 
> > at org.apache.lucene.search.IndexSearcher.search(IndexSearcher.java:445)  
> > at org.apache.lucene.search.IndexSearcher.search(IndexSearcher.java:426)  
> > at org.apache.lucene.search.IndexSearcher.search(IndexSearcher.java:342)  
> > at org.apache.lucene.search.IndexSearcher.search(IndexSearcher.java:330)  
> > at org.elasticsearch.search.query.QueryPhase.execute(QueryPhase.java:194)  
> > ... 9 more
> > 
> > Did I do something wrong in the mapping? When I run searches without the  
> > facet, SearchHit. sourceAsMap().get( "visits" ) gets this field as Integer.
> > 
> > Thanks.

--  
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:** ![Damien\_Alexandre](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/damien_alexandre/32/21566_2.png) [@Damien\_Alexandre](https://discuss.elastic.co/u/Damien_Alexandre)\
**Post date:** [April 19, 2013, 3:43pm UTC](https://discuss.elastic.co/t/failed-to-add-statisticalfacet-on-a-integer-type-field-numberformatexception-invalid-shift-value-in-prefixcoded-string-is-encoded-value-really-an-int/9875/5 "2013-04-19T15:43:39Z")

</div>

Thanks Igor,

I just got the solution moment ago, it was tricky, here is my case:

I have a "catalog" index, with a "stuff" type with mapping fully set,  
and a "foobar" type with some mapping only...

The error was happening when I was running a query with a Facet on my  
"stuff" type,  
on a "articles.price" field set to be a Float.

It take me some time to figure it out but my "foobar" documents were also  
storing an "articles.price" field,  
but I have not set any mapping to it yet! ES guessed it was a "Double" and  
so,  
I'm facing one of Elasticsearch's limitation : _you can't have two field  
with the same name with differents types in the same index_.

The fact is that I was not aware of my "foobar" document fields... Maybe  
the Exception could give some advices about this?

Anyway, glad it's solved now, thanks!

On Friday, April 19, 2013 5:27:43 PM UTC+2, Igor Motov wrote:

> Did you try this solution?  
> [https://groups.google.com/d/topic/elasticsearch/PJ8V6LmYZRo/discussion](https://groups.google.com/d/topic/elasticsearch/PJ8V6LmYZRo/discussion)
> 
> On Friday, April 19, 2013 11:15:51 AM UTC-4, Damien Alexandre wrote:
> 
> > Hi Barak,
> > 
> > I know this is an old question but Google got me here and you seems to  
> > have the exact same issue as me,  
> > did you remember any solution?
> > 
> > Thx!
> > 
> > On Thursday, November 29, 2012 7:56:17 AM UTC+1, barak wrote:
> > 
> > > Hi,
> > > 
> > > I’ve added the following mapping:
> > > 
> > > {"user":{"properties":{"name":{"type":"string","store":"yes"},"visits":{"type":"integer","store":"yes"},"comments":{"type":"string","store":"yes"}}}}
> > > 
> > > And indexing few documents.
> > > 
> > > Using the java API, I want to add facet FacetBuilders.statisticalFacet(  
> > > "facet" ).field( “visits” ), but exception is raised:
> > > 
> > > [2012-11-29 08:25:34,570][DEBUG][action.search.type] [Rose] [user][0],  
> > > node[pkseu6UeSd-cYlT9kA3bWw], [P], s[STARTED]: Failed to execute  
> > > [org.elasticsearch.action.search.SearchRequest@62edc88b]
> > > 
> > > org.elasticsearch.search.query.QueryPhaseExecutionException: [user][0]:  
> > > query[name:"Igor"],from[0],size[10000000]: Query Failed [Failed to execute  
> > > main query]  
> > > at  
> > > org.elasticsearch.search.query.QueryPhase.execute(QueryPhase.java:198)  
> > > at  
> > > org.elasticsearch.search.SearchService.executeQueryPhase(SearchService.java:234)
> > > 
> > > at  
> > > org.elasticsearch.search.action.SearchServiceTransportAction.sendExecuteQuery(SearchServiceTransportAction.java:140)
> > > 
> > > at  
> > > org.elasticsearch.action.search.type.TransportSearchQueryThenFetchAction$AsyncAction.sendExecuteFirstPhase(TransportSearchQueryThenFetchAction.java:80)
> > > 
> > > at  
> > > org.elasticsearch.action.search.type.TransportSearchTypeAction$BaseAsyncAction.performFirstPhase(TransportSearchTypeAction.java:204)
> > > 
> > > at  
> > > org.elasticsearch.action.search.type.TransportSearchTypeAction$BaseAsyncAction.performFirstPhase(TransportSearchTypeAction.java:191)
> > > 
> > > at  
> > > org.elasticsearch.action.search.type.TransportSearchTypeAction$BaseAsyncAction$2.run(TransportSearchTypeAction.java:177)
> > > 
> > > 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:619)
> > > 
> > > Caused by: java.lang.NumberFormatException: Invalid shift value in  
> > > prefixCoded string (is encoded value really an INT?)
> > > 
> > > at  
> > > org.apache.lucene.util.NumericUtils.prefixCodedToInt(NumericUtils.java:232)  
> > > at org.apache.lucene.search.FieldCache$7.parseInt(FieldCache.java:243)  
> > > at  
> > > org.elasticsearch.index.field.data.ints.IntFieldData$IntTypeLoader.collectTerm(IntFieldData.java:150)
> > > 
> > > at  
> > > org.elasticsearch.index.field.data.support.FieldDataLoader.load(FieldDataLoader.java:55)
> > > 
> > > at  
> > > org.elasticsearch.index.field.data.ints.IntFieldData.load(IntFieldData.java:135)
> > > 
> > > at  
> > > org.elasticsearch.index.field.data.ints.IntFieldDataType.load(IntFieldDataType.java:91)
> > > 
> > > at  
> > > org.elasticsearch.index.field.data.ints.IntFieldDataType.load(IntFieldDataType.java:33)
> > > 
> > > at org.elasticsearch.index.field.data.FieldData.load(FieldData.java:111)  
> > > at  
> > > org.elasticsearch.index.cache.field.data.support.AbstractConcurrentMapFieldDataCache.cache(AbstractConcurrentMapFieldDataCache.java:123)
> > > 
> > > at  
> > > org.elasticsearch.search.facet.statistical.StatisticalFacetCollector.doSetNextReader(StatisticalFacetCollector.java:74)
> > > 
> > > at  
> > > org.elasticsearch.search.facet.AbstractFacetCollector.setNextReader(AbstractFacetCollector.java:75)
> > > 
> > > at  
> > > org.elasticsearch.common.lucene.MultiCollector.setNextReader(MultiCollector.java:67)
> > > 
> > > at org.apache.lucene.search.IndexSearcher.search(IndexSearcher.java:576)  
> > > at  
> > > org.elasticsearch.search.internal.ContextIndexSearcher.search(ContextIndexSearcher.java:195)
> > > 
> > > at org.apache.lucene.search.IndexSearcher.search(IndexSearcher.java:445)  
> > > at org.apache.lucene.search.IndexSearcher.search(IndexSearcher.java:426)  
> > > at org.apache.lucene.search.IndexSearcher.search(IndexSearcher.java:342)  
> > > at org.apache.lucene.search.IndexSearcher.search(IndexSearcher.java:330)  
> > > at  
> > > org.elasticsearch.search.query.QueryPhase.execute(QueryPhase.java:194)  
> > > ... 9 more
> > > 
> > > Did I do something wrong in the mapping? When I run searches without the  
> > > facet, SearchHit. sourceAsMap().get( "visits" ) gets this field as Integer.
> > > 
> > > Thanks.

--  
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:40am UTC](https://discuss.elastic.co/t/failed-to-add-statisticalfacet-on-a-integer-type-field-numberformatexception-invalid-shift-value-in-prefixcoded-string-is-encoded-value-really-an-int/9875/6 "2017-07-06T02:40:22Z")

</div>


