# Number Format Exception?

**URL:** <https://discuss.elastic.co/t/number-format-exception/3334>\
**Category:** Elasticsearch\
**Created:** [September 14, 2010, 6:57pm UTC](https://discuss.elastic.co/t/number-format-exception/3334 "2010-09-14T18:57:09Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![bailey](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/bailey/32/3278_2.png) [@bailey](https://discuss.elastic.co/u/bailey)\
**Post date:** [September 14, 2010, 6:57pm UTC](https://discuss.elastic.co/t/number-format-exception/3334/1 "2010-09-14T18:57:09Z")

</div>

Hi All-

I have a couple basic queries that use a field to sort desc or asc.

The query based on views and works great:  
{"query":{"match\_all":{}},"sort":[{"views":"desc"}],"size":1}

The query based on likes is throwing a strange error:  
{"query":{"match\_all":{}},"sort":[{"likes":"desc"}],"size":1}

Error while processing request: /api/ventures/popular, message:  
JavaException:  
org.elasticsearch.action.search.SearchPhaseExecutionException: Failed  
to execute phase [query], total failure; shardFailures {[5de6bee8-  
f7aa-4fca-bab6-aeb6ab1c1cab][nep][1]:  
RemoteTransportException[[Warstrike][inet[/127.0.0.1:9310]][search/  
phase/query]]; nested: QueryPhaseExecutionException[[nep][1]:  
query[_:_],from[0],size[1],sort[\<custom:"likes":  
org.elasticsearch.index.field.data.FieldData$Type$3$1@68895edf\>!]:  
Query Failed [Failed to execute main query]]; nested:  
NumberFormatException[Invalid shift value in prefixCoded string (is  
encoded value really an INT?)]; }

If I pull the entries out via a rest client, the "likes" and "views"  
fields both have the expected integer value.  
And in ES they are apparently exactly the same:  
views: {

```
* omit_term_freq_and_positions: true
* index_name: "views"
* index: "not_analyzed"
* omit_norms: true
* store: "no"
* boost: 1
* precision_step: 4
* term_vector: "no"
* type: "long"

```

}

likes: {

```
* omit_term_freq_and_positions: true
* index_name: "likes"
* index: "not_analyzed"
* omit_norms: true
* store: "no"
* boost: 1
* precision_step: 4
* term_vector: "no"
* type: "long"

```

}

This same behavior is not limited to this one type. I have two other  
types with the same fields (likes and views), same querries and same  
behavior.

Any ideas what could be going?

Thanks.

---

<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:** [September 15, 2010, 10:36am UTC](https://discuss.elastic.co/t/number-format-exception/3334/2 "2010-09-15T10:36:48Z")

</div>

Can you gist a curl recreation?

On Tue, Sep 14, 2010 at 8:57 PM, bailey [matt.bailey@gmail.com](mailto:matt.bailey@gmail.com) wrote:

> Hi All-
> 
> I have a couple basic queries that use a field to sort desc or asc.
> 
> The query based on views and works great:  
> {"query":{"match\_all":{}},"sort":[{"views":"desc"}],"size":1}
> 
> The query based on likes is throwing a strange error:  
> {"query":{"match\_all":{}},"sort":[{"likes":"desc"}],"size":1}
> 
> Error while processing request: /api/ventures/popular, message:  
> JavaException:  
> org.elasticsearch.action.search.SearchPhaseExecutionException: Failed  
> to execute phase [query], total failure; shardFailures {[5de6bee8-  
> f7aa-4fca-bab6-aeb6ab1c1cab][nep][1]:  
> RemoteTransportException[[Warstrike][inet[/127.0.0.1:9310]][search/  
> phase/query]]; nested: QueryPhaseExecutionException[[nep][1]:  
> query[_:_],from[0],size[1],sort[\<custom:"likes":  
> org.elasticsearch.index.field.data.FieldData$Type$3$1@68895edf\>!]:  
> Query Failed [Failed to execute main query]]; nested:  
> NumberFormatException[Invalid shift value in prefixCoded string (is  
> encoded value really an INT?)]; }
> 
> If I pull the entries out via a rest client, the "likes" and "views"  
> fields both have the expected integer value.  
> And in ES they are apparently exactly the same:  
> views: {
> 
> - omit\_term\_freq\_and\_positions: true
> - index\_name: "views"
> - index: "not\_analyzed"
> - omit\_norms: true
> - store: "no"
> - boost: 1
> - precision\_step: 4
> - term\_vector: "no"
> - type: "long"
> 
> }
> 
> likes: {
> 
> - omit\_term\_freq\_and\_positions: true
> - index\_name: "likes"
> - index: "not\_analyzed"
> - omit\_norms: true
> - store: "no"
> - boost: 1
> - precision\_step: 4
> - term\_vector: "no"
> - type: "long"
> 
> }
> 
> This same behavior is not limited to this one type. I have two other  
> types with the same fields (likes and views), same querries and same  
> behavior.
> 
> Any ideas what could be going?
> 
> Thanks.

---

<div class="post-metadata">

**Author:** ![bailey](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/bailey/32/3278_2.png) [@bailey](https://discuss.elastic.co/u/bailey)\
**Post date:** [September 19, 2010, 3:40pm UTC](https://discuss.elastic.co/t/number-format-exception/3334/3 "2010-09-19T15:40:15Z")

</div>

Hi Shay-  
I'm having a tough time recreating it outside of our application (i.e.  
with simple data and curl calls).  
Regardless, I'll post the issue/solution once we pinpoint what's  
causing this.  
Thanks.

On Sep 15, 6:36 am, Shay Banon [shay.ba...@elasticsearch.com](mailto:shay.ba...@elasticsearch.com) wrote:

> Can you gist a curl recreation?
> 
> On Tue, Sep 14, 2010 at 8:57 PM, bailey [matt.bai...@gmail.com](mailto:matt.bai...@gmail.com) wrote:
> 
> > Hi All-
> 
> > I have a couple basic queries that use a field to sort desc or asc.
> 
> > The query based on views and works great:  
> > {"query":{"match\_all":{}},"sort":[{"views":"desc"}],"size":1}
> 
> > The query based on likes is throwing a strange error:  
> > {"query":{"match\_all":{}},"sort":[{"likes":"desc"}],"size":1}
> 
> > Error while processing request: /api/ventures/popular, message:  
> > JavaException:  
> > org.elasticsearch.action.search.SearchPhaseExecutionException: Failed  
> > to execute phase [query], total failure; shardFailures {[5de6bee8-  
> > f7aa-4fca-bab6-aeb6ab1c1cab][nep][1]:  
> > RemoteTransportException[[Warstrike][inet[/127.0.0.1:9310]][search/  
> > phase/query]]; nested: QueryPhaseExecutionException[[nep][1]:  
> > query[_:_],from[0],size[1],sort[\<custom:"likes":  
> > org.elasticsearch.index.field.data.FieldData$Type$3$1@68895edf\>!]:  
> > Query Failed [Failed to execute main query]]; nested:  
> > NumberFormatException[Invalid shift value in prefixCoded string (is  
> > encoded value really an INT?)]; }
> 
> > If I pull the entries out via a rest client, the "likes" and "views"  
> > fields both have the expected integer value.  
> > And in ES they are apparently exactly the same:  
> > views: {
> 
> > - omit\_term\_freq\_and\_positions: true
> > - index\_name: "views"
> > - index: "not\_analyzed"
> > - omit\_norms: true
> > - store: "no"
> > - boost: 1
> > - precision\_step: 4
> > - term\_vector: "no"
> > - type: "long"
> 
> > }
> 
> > likes: {
> 
> > - omit\_term\_freq\_and\_positions: true
> > - index\_name: "likes"
> > - index: "not\_analyzed"
> > - omit\_norms: true
> > - store: "no"
> > - boost: 1
> > - precision\_step: 4
> > - term\_vector: "no"
> > - type: "long"
> 
> > }
> 
> > This same behavior is not limited to this one type. I have two other  
> > types with the same fields (likes and views), same querries and same  
> > behavior.
> 
> > Any ideas what could be going?
> 
> > Thanks.

---

<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:** [September 19, 2010, 6:13pm UTC](https://discuss.elastic.co/t/number-format-exception/3334/4 "2010-09-19T18:13:07Z")

</div>

Strange... . I don't mind running part of your app to try and debug this if  
you want. Contact me directly if its possible.

-shay.banon

On Sun, Sep 19, 2010 at 5:40 PM, bailey [matt.bailey@gmail.com](mailto:matt.bailey@gmail.com) wrote:

> Hi Shay-  
> I'm having a tough time recreating it outside of our application (i.e.  
> with simple data and curl calls).  
> Regardless, I'll post the issue/solution once we pinpoint what's  
> causing this.  
> Thanks.
> 
> On Sep 15, 6:36 am, Shay Banon [shay.ba...@elasticsearch.com](mailto:shay.ba...@elasticsearch.com) wrote:
> 
> > Can you gist a curl recreation?
> > 
> > On Tue, Sep 14, 2010 at 8:57 PM, bailey [matt.bai...@gmail.com](mailto:matt.bai...@gmail.com) wrote:
> > 
> > > Hi All-
> > 
> > > I have a couple basic queries that use a field to sort desc or asc.
> > 
> > > The query based on views and works great:  
> > > {"query":{"match\_all":{}},"sort":[{"views":"desc"}],"size":1}
> > 
> > > The query based on likes is throwing a strange error:  
> > > {"query":{"match\_all":{}},"sort":[{"likes":"desc"}],"size":1}
> > 
> > > Error while processing request: /api/ventures/popular, message:  
> > > JavaException:  
> > > org.elasticsearch.action.search.SearchPhaseExecutionException: Failed  
> > > to execute phase [query], total failure; shardFailures {[5de6bee8-  
> > > f7aa-4fca-bab6-aeb6ab1c1cab][nep][1]:  
> > > RemoteTransportException[[Warstrike][inet[/127.0.0.1:9310]][search/  
> > > phase/query]]; nested: QueryPhaseExecutionException[[nep][1]:  
> > > query[_:_],from[0],size[1],sort[\<custom:"likes":  
> > > org.elasticsearch.index.field.data.FieldData$Type$3$1@68895edf\>!]:  
> > > Query Failed [Failed to execute main query]]; nested:  
> > > NumberFormatException[Invalid shift value in prefixCoded string (is  
> > > encoded value really an INT?)]; }
> > 
> > > If I pull the entries out via a rest client, the "likes" and "views"  
> > > fields both have the expected integer value.  
> > > And in ES they are apparently exactly the same:  
> > > views: {
> > 
> > > - omit\_term\_freq\_and\_positions: true
> > > - index\_name: "views"
> > > - index: "not\_analyzed"
> > > - omit\_norms: true
> > > - store: "no"
> > > - boost: 1
> > > - precision\_step: 4
> > > - term\_vector: "no"
> > > - type: "long"
> > 
> > > }
> > 
> > > likes: {
> > 
> > > - omit\_term\_freq\_and\_positions: true
> > > - index\_name: "likes"
> > > - index: "not\_analyzed"
> > > - omit\_norms: true
> > > - store: "no"
> > > - boost: 1
> > > - precision\_step: 4
> > > - term\_vector: "no"
> > > - type: "long"
> > 
> > > }
> > 
> > > This same behavior is not limited to this one type. I have two other  
> > > types with the same fields (likes and views), same querries and same  
> > > behavior.
> > 
> > > Any ideas what could be going?
> > 
> > > Thanks.

---

<div class="post-metadata">

**Author:** ![bailey](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/bailey/32/3278_2.png) [@bailey](https://discuss.elastic.co/u/bailey)\
**Post date:** [September 19, 2010, 6:40pm UTC](https://discuss.elastic.co/t/number-format-exception/3334/5 "2010-09-19T18:40:50Z")

</div>

Hi Shay-

I believe I tracked down the issue we're facing. It appears that if we  
have the same attribute names (say "likes" and "views") in different  
types under one index and set their types different in one type to the  
next (say long in one and integer in the next) we can recreate the  
error.

Here's an example using curl:

1. Create testbox index  
curl -XPUT '[http://localhost:9311/testbox/](http://localhost:9311/testbox/)'

2. Create likesViewCase mapping, where likes and views are both set to  
'integer' in mapping  
curl -XPUT '[http://localhost:9311/testbox/likesViewsCase/\_mapping](http://localhost:9311/testbox/likesViewsCase/_mapping)' -d  
'  
{  
"likesViewsCase" : {  
"properties" : {  
"user": {"type": "string"},  
"message": {"type": "string"},  
"likes": {"type": "integer"},  
"views": {"type": "integer"}  
}  
}  
}  
'

3. Create likesViewCaseLong mapping, where likes and views are both  
set to 'long' in mapping  
curl -XPUT '[http://localhost:9311/testbox/likesViewsCaseLong/\_mapping](http://localhost:9311/testbox/likesViewsCaseLong/_mapping)'  
-d '  
{  
"likesViewsCase" : {  
"properties" : {  
"user": {"type": "string"},  
"message": {"type": "string"},  
"likes": {"type": "long"},  
"views": {"type": "long"}  
}  
}  
}  
'

4. Add test data to likesViewsCase  
curl -XPUT '[http://localhost:9311/testbox/likesViewsCase/1](http://localhost:9311/testbox/likesViewsCase/1)' -d '  
{  
"user" : "user1",  
"message" : "Test case 1 for likes/views issue.",  
"likes":8,  
"views":9  
}  
'

curl -XPUT '[http://localhost:9311/testbox/likesViewsCase/2](http://localhost:9311/testbox/likesViewsCase/2)' -d '  
{  
"user" : "user2",  
"message" : "Test case 2 for likes/views issue.",  
"likes":22,  
"views":38  
}  
'

curl -XPUT '[http://localhost:9311/testbox/likesViewsCase/3](http://localhost:9311/testbox/likesViewsCase/3)' -d '  
{  
"user" : "user3",  
"message" : "Test case 3 for likes/views issue.",  
"likes":5,  
"views":789  
}  
'

1. Add test data to likesViewsCaseLong  
curl -XPUT '[http://localhost:9311/testbox/likesViewsCaseLong/3](http://localhost:9311/testbox/likesViewsCaseLong/3)' -d '  
{  
"user" : "user4",  
"message" : "Test case 4 for likes/views issue in long type.",  
"likes":50,  
"views":79  
}  
'

2. Search for sorted by views  
curl -XGET '[http://localhost:9311/testbox/likesViewsCase/\_search](http://localhost:9311/testbox/likesViewsCase/_search)' -d '  
{  
"query":{"match\_all":{}},  
"sort":[{"views":"desc"}],  
"size":10  
}  
'

3. Search for sorted by likes  
curl -XGET '[http://localhost:9311/testbox/likesViewsCase/\_search](http://localhost:9311/testbox/likesViewsCase/_search)' -d '  
{  
"query":{"match\_all":{}},  
"sort":[{"likes":"desc"}],  
"size":10  
}  
'

4. The above searches should both return an error similar to:

{"\_shards":{"total":5,"successful":4,"failed":1,"failures":  
[{"index":"testbox","shard":  
3,"reason":"QueryPhaseExecutionException[[testbox][3]:  
query[_:_],from[0],size[10],sort[\<custom:"views":  
org.elasticsearch.index.field.data.FieldData$Type$3$1@691e720f\>!]:  
Query Failed [Failed to execute main query]]; nested:  
NumberFormatException[Invalid shift value in prefixCoded string (is  
encoded value really an INT?)]; "}]},"hits":{"total":  
2,"max\_score":null,"hits":  
[{"\_index":"testbox","\_type":"likesViewsCase","\_id":"3","\_score":null,  
"\_source" :  
{  
"user" : "user3",  
"message" : "Test case 3 for likes/views issue.",  
"likes":5,  
"views":789  
}  
,"sort":[789]},  
{"\_index":"testbox","\_type":"likesViewsCase","\_id":"2","\_score":null,  
"\_source" :  
{  
"user" : "user2",  
"message" : "Test case 2 for likes/views issue.",  
"likes":22,  
"views":38  
}  
,"sort":[38]}]}}

If you exclude steps 3 and 5 the searches should work fine.

Thanks!

On Sep 19, 2:13 pm, Shay Banon [shay.ba...@elasticsearch.com](mailto:shay.ba...@elasticsearch.com) wrote:

> Strange... . I don't mind running part of your app to try and debug this if  
> you want. Contact me directly if its possible.
> 
> -shay.banon
> 
> On Sun, Sep 19, 2010 at 5:40 PM, bailey [matt.bai...@gmail.com](mailto:matt.bai...@gmail.com) wrote:
> 
> > Hi Shay-  
> > I'm having a tough time recreating it outside of our application (i.e.  
> > with simple data and curl calls).  
> > Regardless, I'll post the issue/solution once we pinpoint what's  
> > causing this.  
> > Thanks.
> 
> > On Sep 15, 6:36 am, Shay Banon [shay.ba...@elasticsearch.com](mailto:shay.ba...@elasticsearch.com) wrote:
> > 
> > > Can you gist a curl recreation?
> 
> > > On Tue, Sep 14, 2010 at 8:57 PM, bailey [matt.bai...@gmail.com](mailto:matt.bai...@gmail.com) wrote:
> > > 
> > > > Hi All-
> 
> > > > I have a couple basic queries that use a field to sort desc or asc.
> 
> > > > The query based on views and works great:  
> > > > {"query":{"match\_all":{}},"sort":[{"views":"desc"}],"size":1}
> 
> > > > The query based on likes is throwing a strange error:  
> > > > {"query":{"match\_all":{}},"sort":[{"likes":"desc"}],"size":1}
> 
> > > > Error while processing request: /api/ventures/popular, message:  
> > > > JavaException:  
> > > > org.elasticsearch.action.search.SearchPhaseExecutionException: Failed  
> > > > to execute phase [query], total failure; shardFailures {[5de6bee8-  
> > > > f7aa-4fca-bab6-aeb6ab1c1cab][nep][1]:  
> > > > RemoteTransportException[[Warstrike][inet[/127.0.0.1:9310]][search/  
> > > > phase/query]]; nested: QueryPhaseExecutionException[[nep][1]:  
> > > > query[_:_],from[0],size[1],sort[\<custom:"likes":  
> > > > org.elasticsearch.index.field.data.FieldData$Type$3$1@68895edf\>!]:  
> > > > Query Failed [Failed to execute main query]]; nested:  
> > > > NumberFormatException[Invalid shift value in prefixCoded string (is  
> > > > encoded value really an INT?)]; }
> 
> > > > If I pull the entries out via a rest client, the "likes" and "views"  
> > > > fields both have the expected integer value.  
> > > > And in ES they are apparently exactly the same:  
> > > > views: {
> 
> > > > - omit\_term\_freq\_and\_positions: true
> > > > - index\_name: "views"
> > > > - index: "not\_analyzed"
> > > > - omit\_norms: true
> > > > - store: "no"
> > > > - boost: 1
> > > > - precision\_step: 4
> > > > - term\_vector: "no"
> > > > - type: "long"
> 
> > > > }
> 
> > > > likes: {
> 
> > > > - omit\_term\_freq\_and\_positions: true
> > > > - index\_name: "likes"
> > > > - index: "not\_analyzed"
> > > > - omit\_norms: true
> > > > - store: "no"
> > > > - boost: 1
> > > > - precision\_step: 4
> > > > - term\_vector: "no"
> > > > - type: "long"
> 
> > > > }
> 
> > > > This same behavior is not limited to this one type. I have two other  
> > > > types with the same fields (likes and views), same querries and same  
> > > > behavior.
> 
> > > > Any ideas what could be going?
> 
> > > > Thanks.

---

<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:** [September 19, 2010, 7:19pm UTC](https://discuss.elastic.co/t/number-format-exception/3334/6 "2010-09-19T19:19:08Z")

</div>

Ahh, yes, this is a limitation in elasticsearch. Basically, all types are  
broken down into Lucene Documents, with their "typeness" added by  
elasticsearch. The limit to that is the fact that a field with the same name  
across different types _within the same index_ must be of the same type  
(long/integer/string). The problem does not exists between indices.

Sorry about that!,  
-shay.banon

On Sun, Sep 19, 2010 at 8:40 PM, bailey [matt.bailey@gmail.com](mailto:matt.bailey@gmail.com) wrote:

> Hi Shay-
> 
> I believe I tracked down the issue we're facing. It appears that if we  
> have the same attribute names (say "likes" and "views") in different  
> types under one index and set their types different in one type to the  
> next (say long in one and integer in the next) we can recreate the  
> error.
> 
> Here's an example using curl:
> 
> 1. Create testbox index  
> curl -XPUT '[http://localhost:9311/testbox/](http://localhost:9311/testbox/)'
> 
> 2. Create likesViewCase mapping, where likes and views are both set to  
> 'integer' in mapping  
> curl -XPUT '[http://localhost:9311/testbox/likesViewsCase/\_mapping](http://localhost:9311/testbox/likesViewsCase/_mapping)' -d  
> '  
> {  
> "likesViewsCase" : {  
> "properties" : {  
> "user": {"type": "string"},  
> "message": {"type": "string"},  
> "likes": {"type": "integer"},  
> "views": {"type": "integer"}  
> }  
> }  
> }  
> '
> 
> 3. Create likesViewCaseLong mapping, where likes and views are both  
> set to 'long' in mapping  
> curl -XPUT '[http://localhost:9311/testbox/likesViewsCaseLong/\_mapping](http://localhost:9311/testbox/likesViewsCaseLong/_mapping)'  
> -d '  
> {  
> "likesViewsCase" : {  
> "properties" : {  
> "user": {"type": "string"},  
> "message": {"type": "string"},  
> "likes": {"type": "long"},  
> "views": {"type": "long"}  
> }  
> }  
> }  
> '
> 
> 4. Add test data to likesViewsCase  
> curl -XPUT '[http://localhost:9311/testbox/likesViewsCase/1](http://localhost:9311/testbox/likesViewsCase/1)' -d '  
> {  
> "user" : "user1",  
> "message" : "Test case 1 for likes/views issue.",  
> "likes":8,  
> "views":9  
> }  
> '
> 
> curl -XPUT '[http://localhost:9311/testbox/likesViewsCase/2](http://localhost:9311/testbox/likesViewsCase/2)' -d '  
> {  
> "user" : "user2",  
> "message" : "Test case 2 for likes/views issue.",  
> "likes":22,  
> "views":38  
> }  
> '
> 
> curl -XPUT '[http://localhost:9311/testbox/likesViewsCase/3](http://localhost:9311/testbox/likesViewsCase/3)' -d '  
> {  
> "user" : "user3",  
> "message" : "Test case 3 for likes/views issue.",  
> "likes":5,  
> "views":789  
> }  
> '
> 
> 1. Add test data to likesViewsCaseLong  
> curl -XPUT '[http://localhost:9311/testbox/likesViewsCaseLong/3](http://localhost:9311/testbox/likesViewsCaseLong/3)' -d '  
> {  
> "user" : "user4",  
> "message" : "Test case 4 for likes/views issue in long type.",  
> "likes":50,  
> "views":79  
> }  
> '
> 
> 2. Search for sorted by views  
> curl -XGET '[http://localhost:9311/testbox/likesViewsCase/\_search](http://localhost:9311/testbox/likesViewsCase/_search)' -d '  
> {  
> "query":{"match\_all":{}},  
> "sort":[{"views":"desc"}],  
> "size":10  
> }  
> '
> 
> 3. Search for sorted by likes  
> curl -XGET '[http://localhost:9311/testbox/likesViewsCase/\_search](http://localhost:9311/testbox/likesViewsCase/_search)' -d '  
> {  
> "query":{"match\_all":{}},  
> "sort":[{"likes":"desc"}],  
> "size":10  
> }  
> '
> 
> 4. The above searches should both return an error similar to:
> 
> {"\_shards":{"total":5,"successful":4,"failed":1,"failures":  
> [{"index":"testbox","shard":  
> 3,"reason":"QueryPhaseExecutionException[[testbox][3]:  
> query[_:_],from[0],size[10],sort[\<custom:"views":  
> org.elasticsearch.index.field.data.FieldData$Type$3$1@691e720f\>!]:  
> Query Failed [Failed to execute main query]]; nested:  
> NumberFormatException[Invalid shift value in prefixCoded string (is  
> encoded value really an INT?)]; "}]},"hits":{"total":  
> 2,"max\_score":null,"hits":  
> [{"\_index":"testbox","\_type":"likesViewsCase","\_id":"3","\_score":null,  
> "\_source" :  
> {  
> "user" : "user3",  
> "message" : "Test case 3 for likes/views issue.",  
> "likes":5,  
> "views":789  
> }  
> ,"sort":[789]},  
> {"\_index":"testbox","\_type":"likesViewsCase","\_id":"2","\_score":null,  
> "\_source" :  
> {  
> "user" : "user2",  
> "message" : "Test case 2 for likes/views issue.",  
> "likes":22,  
> "views":38  
> }  
> ,"sort":[38]}]}}
> 
> If you exclude steps 3 and 5 the searches should work fine.
> 
> Thanks!
> 
> On Sep 19, 2:13 pm, Shay Banon [shay.ba...@elasticsearch.com](mailto:shay.ba...@elasticsearch.com) wrote:
> 
> > Strange... . I don't mind running part of your app to try and debug this  
> > if  
> > you want. Contact me directly if its possible.
> > 
> > -shay.banon
> > 
> > On Sun, Sep 19, 2010 at 5:40 PM, bailey [matt.bai...@gmail.com](mailto:matt.bai...@gmail.com) wrote:
> > 
> > > Hi Shay-  
> > > I'm having a tough time recreating it outside of our application (i.e.  
> > > with simple data and curl calls).  
> > > Regardless, I'll post the issue/solution once we pinpoint what's  
> > > causing this.  
> > > Thanks.
> > 
> > > On Sep 15, 6:36 am, Shay Banon [shay.ba...@elasticsearch.com](mailto:shay.ba...@elasticsearch.com) wrote:
> > > 
> > > > Can you gist a curl recreation?
> > 
> > > > On Tue, Sep 14, 2010 at 8:57 PM, bailey [matt.bai...@gmail.com](mailto:matt.bai...@gmail.com)  
> > > > wrote:
> > > > 
> > > > > Hi All-
> > 
> > > > > I have a couple basic queries that use a field to sort desc or asc.
> > 
> > > > > The query based on views and works great:  
> > > > > {"query":{"match\_all":{}},"sort":[{"views":"desc"}],"size":1}
> > 
> > > > > The query based on likes is throwing a strange error:  
> > > > > {"query":{"match\_all":{}},"sort":[{"likes":"desc"}],"size":1}
> > 
> > > > > Error while processing request: /api/ventures/popular, message:  
> > > > > JavaException:  
> > > > > org.elasticsearch.action.search.SearchPhaseExecutionException:  
> > > > > Failed  
> > > > > to execute phase [query], total failure; shardFailures {[5de6bee8-  
> > > > > f7aa-4fca-bab6-aeb6ab1c1cab][nep][1]:  
> > > > > RemoteTransportException[[Warstrike][inet[/127.0.0.1:9310  
> > > > > ]][search/  
> > > > > phase/query]]; nested: QueryPhaseExecutionException[[nep][1]:  
> > > > > query[_:_],from[0],size[1],sort[\<custom:"likes":  
> > > > > org.elasticsearch.index.field.data.FieldData$Type$3$1@68895edf\>!]:  
> > > > > Query Failed [Failed to execute main query]]; nested:  
> > > > > NumberFormatException[Invalid shift value in prefixCoded string (is  
> > > > > encoded value really an INT?)]; }
> > 
> > > > > If I pull the entries out via a rest client, the "likes" and  
> > > > > "views"  
> > > > > fields both have the expected integer value.  
> > > > > And in ES they are apparently exactly the same:  
> > > > > views: {
> > 
> > > > > - omit\_term\_freq\_and\_positions: true
> > > > > - index\_name: "views"
> > > > > - index: "not\_analyzed"
> > > > > - omit\_norms: true
> > > > > - store: "no"
> > > > > - boost: 1
> > > > > - precision\_step: 4
> > > > > - term\_vector: "no"
> > > > > - type: "long"
> > 
> > > > > }
> > 
> > > > > likes: {
> > 
> > > > > - omit\_term\_freq\_and\_positions: true
> > > > > - index\_name: "likes"
> > > > > - index: "not\_analyzed"
> > > > > - omit\_norms: true
> > > > > - store: "no"
> > > > > - boost: 1
> > > > > - precision\_step: 4
> > > > > - term\_vector: "no"
> > > > > - type: "long"
> > 
> > > > > }
> > 
> > > > > This same behavior is not limited to this one type. I have two  
> > > > > other  
> > > > > types with the same fields (likes and views), same querries and  
> > > > > same  
> > > > > behavior.
> > 
> > > > > Any ideas what could be going?
> > 
> > > > > Thanks.

---

<div class="post-metadata">

**Author:** ![bailey](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/bailey/32/3278_2.png) [@bailey](https://discuss.elastic.co/u/bailey)\
**Post date:** [September 20, 2010, 6:23pm UTC](https://discuss.elastic.co/t/number-format-exception/3334/7 "2010-09-20T18:23:45Z")

</div>

Shay-  
Ahhh...Thanks for the info.

On Sep 19, 3:19 pm, Shay Banon [shay.ba...@elasticsearch.com](mailto:shay.ba...@elasticsearch.com) wrote:

> Ahh, yes, this is a limitation in elasticsearch. Basically, all types are  
> broken down into Lucene Documents, with their "typeness" added by  
> elasticsearch. The limit to that is the fact that a field with the same name  
> across different types _within the same index_ must be of the same type  
> (long/integer/string). The problem does not exists between indices.
> 
> Sorry about that!,  
> -shay.banon
> 
> On Sun, Sep 19, 2010 at 8:40 PM, bailey [matt.bai...@gmail.com](mailto:matt.bai...@gmail.com) wrote:
> 
> > Hi Shay-
> 
> > I believe I tracked down the issue we're facing. It appears that if we  
> > have the same attribute names (say "likes" and "views") in different  
> > types under one index and set their types different in one type to the  
> > next (say long in one and integer in the next) we can recreate the  
> > error.
> 
> > Here's an example using curl:
> 
> > 1. Create testbox index  
> > curl -XPUT '[http://localhost:9311/testbox/](http://localhost:9311/testbox/)'
> 
> > 1. Create likesViewCase mapping, where likes and views are both set to  
> > 'integer' in mapping  
> > curl -XPUT '[http://localhost:9311/testbox/likesViewsCase/\_mapping'-d](http://localhost:9311/testbox/likesViewsCase/_mapping'-d)  
> > '  
> > {  
> > "likesViewsCase" : {  
> > "properties" : {  
> > "user": {"type": "string"},  
> > "message": {"type": "string"},  
> > "likes": {"type": "integer"},  
> > "views": {"type": "integer"}  
> > }  
> > }  
> > }  
> > '
> 
> > 1. Create likesViewCaseLong mapping, where likes and views are both  
> > set to 'long' in mapping  
> > curl -XPUT '[http://localhost:9311/testbox/likesViewsCaseLong/\_mapping](http://localhost:9311/testbox/likesViewsCaseLong/_mapping)'  
> > -d '  
> > {  
> > "likesViewsCase" : {  
> > "properties" : {  
> > "user": {"type": "string"},  
> > "message": {"type": "string"},  
> > "likes": {"type": "long"},  
> > "views": {"type": "long"}  
> > }  
> > }  
> > }  
> > '
> 
> > 1. Add test data to likesViewsCase  
> > curl -XPUT '[http://localhost:9311/testbox/likesViewsCase/1'-d](http://localhost:9311/testbox/likesViewsCase/1'-d) '  
> > {  
> > "user" : "user1",  
> > "message" : "Test case 1 for likes/views issue.",  
> > "likes":8,  
> > "views":9  
> > }  
> > '
> 
> > curl -XPUT '[http://localhost:9311/testbox/likesViewsCase/2'-d](http://localhost:9311/testbox/likesViewsCase/2'-d) '  
> > {  
> > "user" : "user2",  
> > "message" : "Test case 2 for likes/views issue.",  
> > "likes":22,  
> > "views":38  
> > }  
> > '
> 
> > curl -XPUT '[http://localhost:9311/testbox/likesViewsCase/3'-d](http://localhost:9311/testbox/likesViewsCase/3'-d) '  
> > {  
> > "user" : "user3",  
> > "message" : "Test case 3 for likes/views issue.",  
> > "likes":5,  
> > "views":789  
> > }  
> > '
> 
> > 1. Add test data to likesViewsCaseLong  
> > curl -XPUT '[http://localhost:9311/testbox/likesViewsCaseLong/3'-d](http://localhost:9311/testbox/likesViewsCaseLong/3'-d) '  
> > {  
> > "user" : "user4",  
> > "message" : "Test case 4 for likes/views issue in long type.",  
> > "likes":50,  
> > "views":79  
> > }  
> > '
> 
> > 1. Search for sorted by views  
> > curl -XGET '[http://localhost:9311/testbox/likesViewsCase/\_search'-d](http://localhost:9311/testbox/likesViewsCase/_search'-d) '  
> > {  
> > "query":{"match\_all":{}},  
> > "sort":[{"views":"desc"}],  
> > "size":10  
> > }  
> > '
> 
> > 1. Search for sorted by likes  
> > curl -XGET '[http://localhost:9311/testbox/likesViewsCase/\_search'-d](http://localhost:9311/testbox/likesViewsCase/_search'-d) '  
> > {  
> > "query":{"match\_all":{}},  
> > "sort":[{"likes":"desc"}],  
> > "size":10  
> > }  
> > '
> 
> > 1. The above searches should both return an error similar to:
> 
> > {"\_shards":{"total":5,"successful":4,"failed":1,"failures":  
> > [{"index":"testbox","shard":  
> > 3,"reason":"QueryPhaseExecutionException[[testbox][3]:  
> > query[_:_],from[0],size[10],sort[\<custom:"views":  
> > org.elasticsearch.index.field.data.FieldData$Type$3$1@691e720f\>!]:  
> > Query Failed [Failed to execute main query]]; nested:  
> > NumberFormatException[Invalid shift value in prefixCoded string (is  
> > encoded value really an INT?)]; "}]},"hits":{"total":  
> > 2,"max\_score":null,"hits":  
> > [{"\_index":"testbox","\_type":"likesViewsCase","\_id":"3","\_score":null,  
> > "\_source" :  
> > {  
> > "user" : "user3",  
> > "message" : "Test case 3 for likes/views issue.",  
> > "likes":5,  
> > "views":789  
> > }  
> > ,"sort":[789]},  
> > {"\_index":"testbox","\_type":"likesViewsCase","\_id":"2","\_score":null,  
> > "\_source" :  
> > {  
> > "user" : "user2",  
> > "message" : "Test case 2 for likes/views issue.",  
> > "likes":22,  
> > "views":38  
> > }  
> > ,"sort":[38]}]}}
> 
> > If you exclude steps 3 and 5 the searches should work fine.
> 
> > Thanks!
> 
> > On Sep 19, 2:13 pm, Shay Banon [shay.ba...@elasticsearch.com](mailto:shay.ba...@elasticsearch.com) wrote:
> > 
> > > Strange... . I don't mind running part of your app to try and debug this  
> > > if  
> > > you want. Contact me directly if its possible.
> 
> > > -shay.banon
> 
> > > On Sun, Sep 19, 2010 at 5:40 PM, bailey [matt.bai...@gmail.com](mailto:matt.bai...@gmail.com) wrote:
> > > 
> > > > Hi Shay-  
> > > > I'm having a tough time recreating it outside of our application (i.e.  
> > > > with simple data and curl calls).  
> > > > Regardless, I'll post the issue/solution once we pinpoint what's  
> > > > causing this.  
> > > > Thanks.
> 
> > > > On Sep 15, 6:36 am, Shay Banon [shay.ba...@elasticsearch.com](mailto:shay.ba...@elasticsearch.com) wrote:
> > > > 
> > > > > Can you gist a curl recreation?
> 
> > > > > On Tue, Sep 14, 2010 at 8:57 PM, bailey [matt.bai...@gmail.com](mailto:matt.bai...@gmail.com)  
> > > > > wrote:
> > > > > 
> > > > > > Hi All-
> 
> > > > > > I have a couple basic queries that use a field to sort desc or asc.
> 
> > > > > > The query based on views and works great:  
> > > > > > {"query":{"match\_all":{}},"sort":[{"views":"desc"}],"size":1}
> 
> > > > > > The query based on likes is throwing a strange error:  
> > > > > > {"query":{"match\_all":{}},"sort":[{"likes":"desc"}],"size":1}
> 
> > > > > > Error while processing request: /api/ventures/popular, message:  
> > > > > > JavaException:  
> > > > > > org.elasticsearch.action.search.SearchPhaseExecutionException:  
> > > > > > Failed  
> > > > > > to execute phase [query], total failure; shardFailures {[5de6bee8-  
> > > > > > f7aa-4fca-bab6-aeb6ab1c1cab][nep][1]:  
> > > > > > RemoteTransportException[[Warstrike][inet[/127.0.0.1:9310  
> > > > > > ]][search/  
> > > > > > phase/query]]; nested: QueryPhaseExecutionException[[nep][1]:  
> > > > > > query[_:_],from[0],size[1],sort[\<custom:"likes":  
> > > > > > org.elasticsearch.index.field.data.FieldData$Type$3$1@68895edf\>!]:  
> > > > > > Query Failed [Failed to execute main query]]; nested:  
> > > > > > NumberFormatException[Invalid shift value in prefixCoded string (is  
> > > > > > encoded value really an INT?)]; }
> 
> > > > > > If I pull the entries out via a rest client, the "likes" and  
> > > > > > "views"  
> > > > > > fields both have the expected integer value.  
> > > > > > And in ES they are apparently exactly the same:  
> > > > > > views: {
> 
> > > > > > - omit\_term\_freq\_and\_positions: true
> > > > > > - index\_name: "views"
> > > > > > - index: "not\_analyzed"
> > > > > > - omit\_norms: true
> > > > > > - store: "no"
> > > > > > - boost: 1
> > > > > > - precision\_step: 4
> > > > > > - term\_vector: "no"
> > > > > > - type: "long"
> 
> > > > > > }
> 
> > > > > > likes: {
> 
> > > > > > - omit\_term\_freq\_and\_positions: true
> > > > > > - index\_name: "likes"
> > > > > > - index: "not\_analyzed"
> > > > > > - omit\_norms: true
> > > > > > - store: "no"
> > > > > > - boost: 1
> > > > > > - precision\_step: 4
> > > > > > - term\_vector: "no"
> > > > > > - type: "long"
> 
> > > > > > }
> 
> > > > > > This same behavior is not limited to this one type. I have two  
> > > > > > other  
> > > > > > types with the same fields (likes and views), same querries and  
> > > > > > same  
> > > > > > behavior.
> 
> > > > > > Any ideas what could be going?
> 
> > > > > > Thanks.

---

<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, 4:19am UTC](https://discuss.elastic.co/t/number-format-exception/3334/8 "2017-07-06T04:19:10Z")

</div>


