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:
-
Create testbox index
curl -XPUT 'http://localhost:9311/testbox/'
-
Create likesViewCase mapping, where likes and views are both set to
'integer' in mapping
curl -XPUT 'http://localhost:9311/testbox/likesViewsCase/_mapping' -d
'
{
"likesViewsCase" : {
"properties" : {
"user": {"type": "string"},
"message": {"type": "string"},
"likes": {"type": "integer"},
"views": {"type": "integer"}
}
}
}
'
-
Create likesViewCaseLong mapping, where likes and views are both
set to 'long' in mapping
curl -XPUT 'http://localhost:9311/testbox/likesViewsCaseLong/_mapping'
-d '
{
"likesViewsCase" : {
"properties" : {
"user": {"type": "string"},
"message": {"type": "string"},
"likes": {"type": "long"},
"views": {"type": "long"}
}
}
}
'
-
Add test data to likesViewsCase
curl -XPUT '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 '
{
"user" : "user2",
"message" : "Test case 2 for likes/views issue.",
"likes":22,
"views":38
}
'
curl -XPUT 'http://localhost:9311/testbox/likesViewsCase/3' -d '
{
"user" : "user3",
"message" : "Test case 3 for likes/views issue.",
"likes":5,
"views":789
}
'
-
Add test data to likesViewsCaseLong
curl -XPUT 'http://localhost:9311/testbox/likesViewsCaseLong/3' -d '
{
"user" : "user4",
"message" : "Test case 4 for likes/views issue in long type.",
"likes":50,
"views":79
}
'
-
Search for sorted by views
curl -XGET 'http://localhost:9311/testbox/likesViewsCase/_search' -d '
{
"query":{"match_all":{}},
"sort":[{"views":"desc"}],
"size":10
}
'
-
Search for sorted by likes
curl -XGET 'http://localhost:9311/testbox/likesViewsCase/_search' -d '
{
"query":{"match_all":{}},
"sort":[{"likes":"desc"}],
"size":10
}
'
-
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 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 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 wrote:
Can you gist a curl recreation?
On Tue, Sep 14, 2010 at 8:57 PM, bailey 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.