# NumberFormatException on facetting by field

**URL:** <https://discuss.elastic.co/t/numberformatexception-on-facetting-by-field/6366>\
**Category:** Elasticsearch\
**Created:** [January 12, 2012, 6:23pm UTC](https://discuss.elastic.co/t/numberformatexception-on-facetting-by-field/6366 "2012-01-12T18:23:18Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![barnybug](https://avatars.discourse-cdn.com/v4/letter/b/f475e1/32.png) [@barnybug](https://discuss.elastic.co/u/barnybug)\
**Post date:** [January 12, 2012, 6:23pm UTC](https://discuss.elastic.co/t/numberformatexception-on-facetting-by-field/6366/1 "2012-01-12T18:23:18Z")

</div>

See test case here:

> <https://gist.github.com/barnybug/1602182>

Hopefully nothing I'm obviously doing wrong - on 0.18.7 I see this  
error to the query:

> <https://gist.github.com/barnybug/1602207>

"QueryPhaseExecutionException[[test][2]:  
query[filtered(ConstantScore(_:_))-

> FilterCacheFilterWrapper(\_type:a)],from[0],size[10]: Query Failed  
> [Failed to execute main query]]; nested: NumberFormatException[Invalid  
> shift value in prefixCoded string (is encoded value really an INT?)];  
> "

Help appreciated!

regards,

Barnaby

---

<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:** [January 12, 2012, 9:56pm UTC](https://discuss.elastic.co/t/numberformatexception-on-facetting-by-field/6366/2 "2012-01-12T21:56:14Z")

</div>

You have a field named field1 on both mapping types, a and b, but they are  
not of the same field type. The first is an integer, the second is a long  
(automatically derived). For facets / sorting, field types with the same  
name across mapping types must be the same (its an optimization to conserve  
memory) even though you specifically define the mapping type to search on.

On Thu, Jan 12, 2012 at 8:23 PM, barnybug [barnybug@googlemail.com](mailto:barnybug@googlemail.com) wrote:

> See test case here:  
> [gist:1602182 · GitHub](https://gist.github.com/1602182)
> 
> Hopefully nothing I'm obviously doing wrong - on 0.18.7 I see this  
> error to the query:  
> [gist:1602207 · GitHub](https://gist.github.com/1602207)  
> "QueryPhaseExecutionException[[test][2]:  
> query[filtered(ConstantScore(_:_))-
> 
> > FilterCacheFilterWrapper(\_type:a)],from[0],size[10]: Query Failed  
> > [Failed to execute main query]]; nested: NumberFormatException[Invalid  
> > shift value in prefixCoded string (is encoded value really an INT?)];  
> > "
> 
> Help appreciated!
> 
> regards,
> 
> Barnaby

---

<div class="post-metadata">

**Author:** ![barnybug](https://avatars.discourse-cdn.com/v4/letter/b/f475e1/32.png) [@barnybug](https://discuss.elastic.co/u/barnybug)\
**Post date:** [January 13, 2012, 11:07am UTC](https://discuss.elastic.co/t/numberformatexception-on-facetting-by-field/6366/3 "2012-01-13T11:07:44Z")

</div>

Good spot. Thanks.

regards,

Barnaby

On Jan 12, 9:56 pm, Shay Banon [kim...@gmail.com](mailto:kim...@gmail.com) wrote:

> You have a field named field1 on both mapping types, a and b, but they are  
> not of the same field type. The first is an integer, the second is a long  
> (automatically derived). For facets / sorting, field types with the same  
> name across mapping types must be the same (its an optimization to conserve  
> memory) even though you specifically define the mapping type to search on.
> 
> On Thu, Jan 12, 2012 at 8:23 PM, barnybug [barny...@googlemail.com](mailto:barny...@googlemail.com) wrote:
> 
> > See test case here:  
> > [gist:1602182 · GitHub](https://gist.github.com/1602182)
> 
> > Hopefully nothing I'm obviously doing wrong - on 0.18.7 I see this  
> > error to the query:  
> > [gist:1602207 · GitHub](https://gist.github.com/1602207)  
> > "QueryPhaseExecutionException[[test][2]:  
> > query[filtered(ConstantScore(_:_))-
> > 
> > > FilterCacheFilterWrapper(\_type:a)],from[0],size[10]: Query Failed  
> > > [Failed to execute main query]]; nested: NumberFormatException[Invalid  
> > > shift value in prefixCoded string (is encoded value really an INT?)];  
> > > "
> 
> > Help appreciated!
> 
> > regards,
> 
> > Barnaby

---

<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, 3:42am UTC](https://discuss.elastic.co/t/numberformatexception-on-facetting-by-field/6366/4 "2017-07-06T03:42:47Z")

</div>


