title: ElasticSearch - query_shard_exception | No mapping found for [timestamp] in order to sort on-Works through kibana dev tools but 400 error through API
body: <p>Facing a weird issue in querying Elastic search where the query is giving correct response when run through Kibana dev tools but hitting through Rest API is giving 400 error of No mapping found. Below are the details.
  Query through Kibana dev tool :</p>
  <p>GET diagnostics/_search?pretty=true&amp;q=OTA4MjYxODM3NQ&amp;size=6&amp;sort=timestamp:desc</p>
  <p>Getting response on the above query :</p>
  <pre><code>
      {
        &quot;took&quot;: 0,
        &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;: 22,
          &quot;max_score&quot;: null,
          &quot;hits&quot;: [
            {
      .......
      }
      ]
      }
  
  </code></pre>
  <p>But when I am hitting the same through Rest API below is the scenario :
  API - http://IP:9200/diagnostics/_search?pretty=true&amp;q=OTA4MjYxODM3NQ&amp;size=6&amp;sort=timestamp:desc</p>
  <p>Response :</p>
  <pre><code>
      {
          &quot;error&quot;: {
              &quot;root_cause&quot;: [
                  {
                      &quot;type&quot;: &quot;query_shard_exception&quot;,
                      &quot;reason&quot;: &quot;No mapping found for [timestamp] in order to sort on&quot;,
                      &quot;index_uuid&quot;: &quot;JYOLtQ_URBGKnhxUWzD3dA&quot;,
                      &quot;index&quot;: &quot;diagnostics&quot;
                  }
              ],
              &quot;type&quot;: &quot;search_phase_execution_exception&quot;,
              &quot;reason&quot;: &quot;all shards failed&quot;,
              &quot;phase&quot;: &quot;query&quot;,
              &quot;grouped&quot;: true,
              &quot;failed_shards&quot;: [
                  {
                      &quot;shard&quot;: 0,
                      &quot;index&quot;: &quot;diagnostics&quot;,
                      &quot;node&quot;: &quot;kisW84q1SbKEz7KQiOtY7Q&quot;,
                      &quot;reason&quot;: {
                          &quot;type&quot;: &quot;query_shard_exception&quot;,
                          &quot;reason&quot;: &quot;No mapping found for [timestamp] in order to sort on&quot;,
                          &quot;index_uuid&quot;: &quot;JYOLtQ_URBGKnhxUWzD3dA&quot;,
                          &quot;index&quot;: &quot;diagnostics&quot;
                      }
                  }
              ]
          },
          &quot;status&quot;: 400
      }
  
  </code></pre>
  <p>Please help me as I find this very strange as through code when I am calling API, it is failing and I am stuck to understand the root cause of this.</p>
  <p>GET diagnostics details</p>
  <pre><code>http://IP(A):9200/diagnostics
  {
      &quot;diagnostics&quot;: {
          &quot;aliases&quot;: {},
          &quot;mappings&quot;: {},
          &quot;settings&quot;: {
              &quot;index&quot;: {
                  &quot;creation_date&quot;: &quot;1613465495276&quot;,
                  &quot;number_of_shards&quot;: &quot;5&quot;,
                  &quot;number_of_replicas&quot;: &quot;0&quot;,
                  &quot;uuid&quot;: &quot;JYOLtQ_URBGKnhxUWzD3dA&quot;,
                  &quot;version&quot;: {
                      &quot;created&quot;: &quot;5050199&quot;
                  },
                  &quot;provided_name&quot;: &quot;diagnostics&quot;
              }
          }
      }
  }
  </code></pre>
  <p>Through Kibana dev tools running on IP(A):5601-</p>
  <pre><code>GET diagnostics
  {
    &quot;diagnostics&quot;: {
      &quot;aliases&quot;: {},
      &quot;mappings&quot;: {
        &quot;results&quot;: {
          &quot;properties&quot;: {
  details are present here....
  }
  &quot;number_of_shards&quot;: &quot;5&quot;,
          &quot;provided_name&quot;: &quot;diagnostics&quot;,
          &quot;creation_date&quot;: &quot;1545374854111&quot;,
          &quot;number_of_replicas&quot;: &quot;0&quot;,
          &quot;uuid&quot;: &quot;CB7Vci8MTNiW2F85_S4z4Q&quot;,
          &quot;version&quot;: {
            &quot;created&quot;: &quot;5050199&quot;
          }
        }
      }
    }
  }
  </code></pre>