title: Elasticsearch NumberFormatException when sorting by numeric and date fields
body: <p>I am attempting to sort on two fields, one is a date field the other is an integer field. I have verified that the fields are mapped correctly and that the values for all of the indexed documents have the correct data types, however every time i try to sort by the numeric field I ES returns an exception [java.lang.NumberFormatException: Invalid shift value in prefixCoded bytes (is encoded value really an INT?)].</p>
  
  <p>The wierd thing is that it returns results and they seem to be sorted correctly so I'm not entirely sure what effect this is having but I know I should not have any errors in the response.</p>
  
  <p>Here is a the mapping:</p>
  
  <pre><code>{
     "blcdt.products": {
        "mappings": {
           "review_143758": {
              "properties": {
                 "date_reviewed": {
                    "type": "date",
                    "format": "YYYY-MM-dd"
                 },
                 "description": {
                    "type": "string"
                 },
                 "manufacturer": {
                    "type": "string",
                    "index": "not_analyzed"
                 },
                 "model_number": {
                    "type": "string",
                    "boost": 2,
                    "index": "not_analyzed",
                    "norms": {
                       "enabled": true
                    }
                 },
                 "msrp": {
                    "type": "float"
                 },
                 "product": {
                    "type": "string"
                 },
                 "product_name": {
                    "type": "string",
                    "boost": 2,
                    "fields": {
                       "full": {
                          "type": "string",
                          "boost": 4,
                          "index": "not_analyzed",
                          "norms": {
                             "enabled": true
                          }
                       }
                    }
                 },
                 "product_type": {
                    "type": "string",
                    "index": "not_analyzed"
                 },
                 "review_category": {
                    "type": "string",
                    "index": "not_analyzed"
                 },
                 "review_title": {
                    "type": "string"
                 },
                 "review_type": {
                    "type": "string",
                    "index": "not_analyzed"
                 },
                 "review_type_priority": {
                    "type": "integer"
                 },
                 "score": {
                    "type": "float"
                 },
  
              }
           }
        }
     }
  }
  </code></pre>
  
  <p>Here is a query that throws the exception:</p>
  
  <pre><code>POST /blcdt.products/review_143758/_search?pretty=true
  {
     "query": {
        "filtered": {
           "filter": [
              {
                 "term": {
                    "review_category": "Game Reviews"
                 }
              }
           ]
        }
     },
     "from": 0,
     "size": 8,
     "sort": [
        {
           "review_type_priority": {
              "order": "desc"
           }
        },
        {
           "date_reviewed": {
              "order": "desc"
           }
        }
     ],
     "fields": [
        "review_title",
        "review_type",
        "score"
     ]
  }
  </code></pre>
  
  <p>and here is the abbreviated response from ES:</p>
  
  <pre><code>{
     "took": 2,
     "timed_out": false,
     "_shards": {
        "total": 5,
        "successful": 1,
        "failed": 4,
        "failures": [
           {
              "index": "blcdt.products",
              "shard": 2,
              "status": 500,
              "reason": "QueryPhaseExecutionException[[blcdt.products][2]: query[filtered(ConstantScore(cache(review_category:Game Reviews)))-&gt;cache(_type:review_143758)],from[0],size[8],sort[&lt;custom:\"review_type_priority\": org.elasticsearch.index.fielddata.fieldcomparator.LongValuesComparatorSource@44ecbc5&gt;!,&lt;custom:\"date_reviewed\": org.elasticsearch.index.fielddata.fieldcomparator.LongValuesComparatorSource@5123f4b8&gt;!]: Query Failed [Failed to execute main query]]; nested: ElasticsearchException[java.lang.NumberFormatException: Invalid shift value in prefixCoded bytes (is encoded value really an INT?)]; nested: UncheckedExecutionException[java.lang.NumberFormatException: Invalid shift value in prefixCoded bytes (is encoded value really an INT?)]; nested: NumberFormatException[Invalid shift value in prefixCoded bytes (is encoded value really an INT?)]; "
           },
           {
              "index": "blcdt.products",
              "shard": 3,
              "status": 500,
              "reason": "QueryPhaseExecutionException[[blcdt.products][3]: query[filtered(ConstantScore(cache(review_category:Game Reviews)))-&gt;cache(_type:review_143758)],from[0],size[8],sort[&lt;custom:\"review_type_priority\": org.elasticsearch.index.fielddata.fieldcomparator.LongValuesComparatorSource@281d24cc&gt;!,&lt;custom:\"date_reviewed\": org.elasticsearch.index.fielddata.fieldcomparator.LongValuesComparatorSource@115ae1a7&gt;!]: Query Failed [Failed to execute main query]]; nested: ElasticsearchException[java.lang.NumberFormatException: Invalid shift value in prefixCoded bytes (is encoded value really an INT?)]; nested: UncheckedExecutionException[java.lang.NumberFormatException: Invalid shift value in prefixCoded bytes (is encoded value really an INT?)]; nested: NumberFormatException[Invalid shift value in prefixCoded bytes (is encoded value really an INT?)]; "
           },
           {
              "index": "blcdt.products",
              "shard": 4,
              "status": 500,
              "reason": "QueryPhaseExecutionException[[blcdt.products][4]: query[filtered(ConstantScore(cache(review_category:Game Reviews)))-&gt;cache(_type:review_143758)],from[0],size[8],sort[&lt;custom:\"review_type_priority\": org.elasticsearch.index.fielddata.fieldcomparator.LongValuesComparatorSource@41238b2a&gt;!,&lt;custom:\"date_reviewed\": org.elasticsearch.index.fielddata.fieldcomparator.LongValuesComparatorSource@48593cf&gt;!]: Query Failed [Failed to execute main query]]; nested: ElasticsearchException[java.lang.NumberFormatException: Invalid shift value in prefixCoded bytes (is encoded value really an INT?)]; nested: UncheckedExecutionException[java.lang.NumberFormatException: Invalid shift value in prefixCoded bytes (is encoded value really an INT?)]; nested: NumberFormatException[Invalid shift value in prefixCoded bytes (is encoded value really an INT?)]; "
           },
           {
              "index": "blcdt.products",
              "shard": 0,
              "status": 500,
              "reason": "QueryPhaseExecutionException[[blcdt.products][0]: query[filtered(ConstantScore(cache(review_category:Game Reviews)))-&gt;cache(_type:review_143758)],from[0],size[8],sort[&lt;custom:\"review_type_priority\": org.elasticsearch.index.fielddata.fieldcomparator.LongValuesComparatorSource@1cbd767c&gt;!,&lt;custom:\"date_reviewed\": org.elasticsearch.index.fielddata.fieldcomparator.LongValuesComparatorSource@5aadd5a1&gt;!]: Query Failed [Failed to execute main query]]; nested: ElasticsearchException[java.lang.NumberFormatException: Invalid shift value in prefixCoded bytes (is encoded value really an INT?)]; nested: UncheckedExecutionException[java.lang.NumberFormatException: Invalid shift value in prefixCoded bytes (is encoded value really an INT?)]; nested: NumberFormatException[Invalid shift value in prefixCoded bytes (is encoded value really an INT?)]; "
           }
        ]
     },
     "hits": {
        "total": 41,
        "max_score": null,
        "hits": [
           {
              "_index": "blcdt.products",
              "_type": "review_143758",
              "_id": "599606",
              "_score": null,
              "fields": {
                 "score": [
                    8
                 ],
                 "review_type": [
                    "review"
                 ],
                 "review_title": [
                    "Entwined review"
                 ]
              },
              "sort": [
                 100,
                 1403648392
              ]
           },
           ...
           {
              "_index": "blcdt.products",
              "_type": "review_143758",
              "_id": "452429",
              "_score": null,
              "fields": {
                 "score": [
                    9
                 ],
                 "review_type": [
                    "review"
                 ],
                 "review_title": [
                    "Dark Souls II review"
                 ]
              },
              "sort": [
                 100,
                 1394840094
              ]
           }
        ]
     }
  }
  </code></pre>