# No mapping found for \[timestamp\] in order to sort on

**URL:** <https://discuss.elastic.co/t/no-mapping-found-for-timestamp-in-order-to-sort-on/142847>\
**Category:** Elasticsearch\
**Created:** [August 3, 2018, 5:48am UTC](https://discuss.elastic.co/t/no-mapping-found-for-timestamp-in-order-to-sort-on/142847 "2018-08-03T05:48:56Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![APJ](https://avatars.discourse-cdn.com/v4/letter/a/b5ac83/32.png) [@APJ](https://discuss.elastic.co/u/APJ)\
**Post date:** [August 3, 2018, 5:48am UTC](https://discuss.elastic.co/t/no-mapping-found-for-timestamp-in-order-to-sort-on/142847/1 "2018-08-03T05:48:56Z")

</div>

I have developed a small node.js server, which will use the elasticsearch npm module to get the latest JSON document based on timestamp.

Here is the code for it,

```
let express = require('express');
let app = express();
let elasticsearch = require('elasticsearch');

app.listen(3000, function() {
    console.log('Example app listening on port 3000!');
});

let client = new elasticsearch.Client({
    host: ['http://localhost:9200']
});

client.ping({
    requestTimeout: 30000,
}, function(error) {
    if (error) {
        console.error('elasticsearch cluster is down!');
    } else {
        console.log('Everything is ok');
    }
});

async function getResponse() {

    const response = await client.search({
        index: 'weather',
        type: 'doc',
        body: {
            sort: [{ "timestamp": { "order": "desc" } }],
            size: 1,
            query: { match_all: {} }
        }
    });

    console.log(response);

}

getResponse();

```

When In run the code, I get an error like this,

`(node:11372) UnhandledPromiseRejectionWarning: Error: [query_shard_exception] No mapping found for [timestamp] in order to sort on, with { index_uuid="j-TaPYgLRhuYyiJJjg1tYg" & index="weather" }`

Is there anything wrong with the search config? Would appreciate if anybody could help. Thanks!

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [August 3, 2018, 7:38am UTC](https://discuss.elastic.co/t/no-mapping-found-for-timestamp-in-order-to-sort-on/142847/2 "2018-08-03T07:38:21Z")

</div>

What is the mapping of your weather index?

---

<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:** [August 31, 2018, 7:38am UTC](https://discuss.elastic.co/t/no-mapping-found-for-timestamp-in-order-to-sort-on/142847/3 "2018-08-31T07:38:28Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
