<p dir="auto">We recently migrated our ES 1.1.1 cluster to ES 1.2.2, after that we found that one field 'displayPublishedDateTime', which is defined as dataOptionalTime type in the mapping, seems corrupted and not able to order by it in the query.<br>
In the query, when order by desc on it, its sort value is '\b', and order by asc, its sort value is shown as '' \u0001\u0000\u0000\u0000(aC3@X", see the following query and results. In other queries, which order by 'displayPublishedDateTime', the order actually didn't take effect. It looks like that Elasticsearch was unable to get the correct sort value for this field.</p>
<p dir="auto">Query</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="GET /doc-v2/_search
{
  &quot;query&quot;: {
      &quot;match&quot;: {
         &quot;_id&quot;: &quot;AAUYRY&quot;
      }
  },
  &quot;_source&quot;:[
    &quot;_id&quot;,
    &quot;_document.displayPublishedDateTime&quot;,
    ],
  &quot;sort&quot;: [
    {
      &quot;_document.displayPublishedDateTime&quot;: {
        &quot;order&quot;: &quot;desc&quot;
      }
    }
  ]
}"><pre class="notranslate"><code class="notranslate">GET /doc-v2/_search
{
  "query": {
      "match": {
         "_id": "AAUYRY"
      }
  },
  "_source":[
    "_id",
    "_document.displayPublishedDateTime",
    ],
  "sort": [
    {
      "_document.displayPublishedDateTime": {
        "order": "desc"
      }
    }
  ]
}
</code></pre></div>
<p dir="auto">Results for 'desc'</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="{
   &quot;took&quot;: 46,
   &quot;timed_out&quot;: false,
   &quot;_shards&quot;: {
      &quot;total&quot;: 25,
      &quot;successful&quot;: 25,
      &quot;failed&quot;: 0
   },
   &quot;hits&quot;: {
      &quot;total&quot;: 1,
      &quot;max_score&quot;: null,
      &quot;hits&quot;: [
         {
            &quot;_index&quot;: &quot;doc-v2&quot;,
            &quot;_type&quot;: &quot;article&quot;,
            &quot;_id&quot;: &quot;AAUYRY&quot;,
            &quot;_score&quot;: null,
            &quot;_source&quot;: {
               &quot;_document&quot;: {
                  &quot;displayPublishedDateTime&quot;: &quot;2014-05-20T06:58:47Z&quot;
               }
            },
            &quot;sort&quot;: [
               &quot;\\\b&quot;
            ]
         }
      ]
   }
}"><pre class="notranslate"><code class="notranslate">{
   "took": 46,
   "timed_out": false,
   "_shards": {
      "total": 25,
      "successful": 25,
      "failed": 0
   },
   "hits": {
      "total": 1,
      "max_score": null,
      "hits": [
         {
            "_index": "doc-v2",
            "_type": "article",
            "_id": "AAUYRY",
            "_score": null,
            "_source": {
               "_document": {
                  "displayPublishedDateTime": "2014-05-20T06:58:47Z"
               }
            },
            "sort": [
               "\\\b"
            ]
         }
      ]
   }
}
</code></pre></div>
<p dir="auto">Results for 'asc'</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="{
   &quot;took&quot;: 78,
   &quot;timed_out&quot;: false,
   &quot;_shards&quot;: {
      &quot;total&quot;: 25,
      &quot;successful&quot;: 25,
      &quot;failed&quot;: 0
   },
   &quot;hits&quot;: {
      &quot;total&quot;: 1,
      &quot;max_score&quot;: null,
      &quot;hits&quot;: [
         {
            &quot;_index&quot;: &quot;doc-v2&quot;,
            &quot;_type&quot;: &quot;article&quot;,
            &quot;_id&quot;: &quot;AAUYRY&quot;,
            &quot;_score&quot;: null,
            &quot;_source&quot;: {
               &quot;_document&quot;: {
                  &quot;displayPublishedDateTime&quot;: &quot;2014-05-20T06:58:47Z&quot;
               }
            },
            &quot;sort&quot;: [
               &quot; \u0001\u0000\u0000\u0000(aC3@X&quot;
            ]
         }
      ]
   }
}"><pre class="notranslate"><code class="notranslate">{
   "took": 78,
   "timed_out": false,
   "_shards": {
      "total": 25,
      "successful": 25,
      "failed": 0
   },
   "hits": {
      "total": 1,
      "max_score": null,
      "hits": [
         {
            "_index": "doc-v2",
            "_type": "article",
            "_id": "AAUYRY",
            "_score": null,
            "_source": {
               "_document": {
                  "displayPublishedDateTime": "2014-05-20T06:58:47Z"
               }
            },
            "sort": [
               " \u0001\u0000\u0000\u0000(aC3@X"
            ]
         }
      ]
   }
}
</code></pre></div>
<p dir="auto">When querying with "preference": "_local", the _source is returned instead of the requested fields.</p>
<p dir="auto"><code class="notranslate">$ curl -XPUT 'http://ks398280.kimsufi.com:9200/test/test/1' -d '{"user": "foo", "amount": 35, "data": "some more data"}'</code></p>
<div class="highlight highlight-source-json notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="$ curl -XPOST 'http://ks398280.kimsufi.com:9200/test/test/_search?pretty' -d  '{
    &quot;query&quot;: {
        &quot;match&quot;: {
            &quot;data&quot;: {
                &quot;query&quot;: &quot;some&quot;
             }
        }
    },
    &quot;fields&quot;: [&quot;user&quot;, &quot;amount&quot;]
}'

{
  &quot;took&quot; : 1,
  &quot;timed_out&quot; : false,
  &quot;_shards&quot; : {
    &quot;total&quot; : 5,
    &quot;successful&quot; : 5,
    &quot;failed&quot; : 0
  },
  &quot;hits&quot; : {
    &quot;total&quot; : 1,
    &quot;max_score&quot; : 0.15342641,
    &quot;hits&quot; : [ {
      &quot;_index&quot; : &quot;test&quot;,
      &quot;_type&quot; : &quot;test&quot;,
      &quot;_id&quot; : &quot;1&quot;,
      &quot;_score&quot; : 0.15342641,
      &quot;fields&quot; : {
        &quot;amount&quot; : 35,
        &quot;user&quot; : &quot;foo&quot;
      }
    } ]
  }
}"><pre class="notranslate"><span class="pl-ii">$ curl -XPOST 'http://ks398280.kimsufi.com:9200/test/test/_search?pretty' -d  '{</span>
    <span class="pl-ent">"query"</span>: {
        <span class="pl-ent">"match"</span>: {
            <span class="pl-ent">"data"</span>: {
                <span class="pl-ent">"query"</span>: <span class="pl-s"><span class="pl-pds">"</span>some<span class="pl-pds">"</span></span>
             }
        }
    },
    <span class="pl-ent">"fields"</span>: [<span class="pl-s"><span class="pl-pds">"</span>user<span class="pl-pds">"</span></span>, <span class="pl-s"><span class="pl-pds">"</span>amount<span class="pl-pds">"</span></span>]
<span class="pl-ii">}'</span>

{
  <span class="pl-ent">"took"</span> : <span class="pl-c1">1</span>,
  <span class="pl-ent">"timed_out"</span> : <span class="pl-c1">false</span>,
  <span class="pl-ent">"_shards"</span> : {
    <span class="pl-ent">"total"</span> : <span class="pl-c1">5</span>,
    <span class="pl-ent">"successful"</span> : <span class="pl-c1">5</span>,
    <span class="pl-ent">"failed"</span> : <span class="pl-c1">0</span>
  },
  <span class="pl-ent">"hits"</span> : {
    <span class="pl-ent">"total"</span> : <span class="pl-c1">1</span>,
    <span class="pl-ent">"max_score"</span> : <span class="pl-c1">0.15342641</span>,
    <span class="pl-ent">"hits"</span> : [ {
      <span class="pl-ent">"_index"</span> : <span class="pl-s"><span class="pl-pds">"</span>test<span class="pl-pds">"</span></span>,
      <span class="pl-ent">"_type"</span> : <span class="pl-s"><span class="pl-pds">"</span>test<span class="pl-pds">"</span></span>,
      <span class="pl-ent">"_id"</span> : <span class="pl-s"><span class="pl-pds">"</span>1<span class="pl-pds">"</span></span>,
      <span class="pl-ent">"_score"</span> : <span class="pl-c1">0.15342641</span>,
      <span class="pl-ent">"fields"</span> : {
        <span class="pl-ent">"amount"</span> : <span class="pl-c1">35</span>,
        <span class="pl-ent">"user"</span> : <span class="pl-s"><span class="pl-pds">"</span>foo<span class="pl-pds">"</span></span>
      }
    } ]
  }
}</pre></div>
<div class="highlight highlight-source-json notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="$ curl -XPOST 'http://ks398280.kimsufi.com:9200/test/test/_search?pretty' -d  '{
    &quot;query&quot;: {
        &quot;match&quot;: {
            &quot;data&quot;: {
                &quot;query&quot;: &quot;some&quot;
             }
        },
        &quot;preference&quot;: &quot;_local&quot;
    },
    &quot;fields&quot;: [&quot;user&quot;, &quot;amount&quot;],
}'

{
  &quot;took&quot; : 1,
  &quot;timed_out&quot; : false,
  &quot;_shards&quot; : {
    &quot;total&quot; : 5,
    &quot;successful&quot; : 5,
    &quot;failed&quot; : 0
  },
  &quot;hits&quot; : {
    &quot;total&quot; : 1,
    &quot;max_score&quot; : 0.15342641,
    &quot;hits&quot; : [ {
      &quot;_index&quot; : &quot;test&quot;,
      &quot;_type&quot; : &quot;test&quot;,
      &quot;_id&quot; : &quot;1&quot;,
      &quot;_score&quot; : 0.15342641, &quot;_source&quot; : {&quot;user&quot;: &quot;foo&quot;, &quot;amount&quot;: 35, &quot;data&quot;: &quot;some more data&quot;}
    } ]
  }
}"><pre class="notranslate"><span class="pl-ii">$ curl -XPOST 'http://ks398280.kimsufi.com:9200/test/test/_search?pretty' -d  '{</span>
    <span class="pl-ent">"query"</span>: {
        <span class="pl-ent">"match"</span>: {
            <span class="pl-ent">"data"</span>: {
                <span class="pl-ent">"query"</span>: <span class="pl-s"><span class="pl-pds">"</span>some<span class="pl-pds">"</span></span>
             }
        },
        <span class="pl-ent">"preference"</span>: <span class="pl-s"><span class="pl-pds">"</span>_local<span class="pl-pds">"</span></span>
    },
    <span class="pl-ent">"fields"</span>: [<span class="pl-s"><span class="pl-pds">"</span>user<span class="pl-pds">"</span></span>, <span class="pl-s"><span class="pl-pds">"</span>amount<span class="pl-pds">"</span></span>],
<span class="pl-ii">}'</span>

{
  <span class="pl-ent">"took"</span> : <span class="pl-c1">1</span>,
  <span class="pl-ent">"timed_out"</span> : <span class="pl-c1">false</span>,
  <span class="pl-ent">"_shards"</span> : {
    <span class="pl-ent">"total"</span> : <span class="pl-c1">5</span>,
    <span class="pl-ent">"successful"</span> : <span class="pl-c1">5</span>,
    <span class="pl-ent">"failed"</span> : <span class="pl-c1">0</span>
  },
  <span class="pl-ent">"hits"</span> : {
    <span class="pl-ent">"total"</span> : <span class="pl-c1">1</span>,
    <span class="pl-ent">"max_score"</span> : <span class="pl-c1">0.15342641</span>,
    <span class="pl-ent">"hits"</span> : [ {
      <span class="pl-ent">"_index"</span> : <span class="pl-s"><span class="pl-pds">"</span>test<span class="pl-pds">"</span></span>,
      <span class="pl-ent">"_type"</span> : <span class="pl-s"><span class="pl-pds">"</span>test<span class="pl-pds">"</span></span>,
      <span class="pl-ent">"_id"</span> : <span class="pl-s"><span class="pl-pds">"</span>1<span class="pl-pds">"</span></span>,
      <span class="pl-ent">"_score"</span> : <span class="pl-c1">0.15342641</span>, <span class="pl-ent">"_source"</span> : {<span class="pl-ent">"user"</span>: <span class="pl-s"><span class="pl-pds">"</span>foo<span class="pl-pds">"</span></span>, <span class="pl-ent">"amount"</span>: <span class="pl-c1">35</span>, <span class="pl-ent">"data"</span>: <span class="pl-s"><span class="pl-pds">"</span>some more data<span class="pl-pds">"</span></span>}
    } ]
  }
}</pre></div>