# Elasticsearch.js and Index Date Math

**URL:** <https://discuss.elastic.co/t/elasticsearch-js-and-index-date-math/67775>\
**Category:** Elasticsearch\
**Created:** [December 1, 2016, 2:24pm UTC](https://discuss.elastic.co/t/elasticsearch-js-and-index-date-math/67775 "2016-12-01T14:24:53Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![derEremit](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dereremit/32/12082_2.png) [@derEremit](https://discuss.elastic.co/u/derEremit)\
**Post date:** [December 1, 2016, 2:24pm UTC](https://discuss.elastic.co/t/elasticsearch-js-and-index-date-math/67775/1 "2016-12-01T14:24:53Z")

</div>

I got following query, and would like to use date math on the index part  
like  
index = "\<logstash-stats-short-{now/d}\>"  
query = {  
index: this.config.logstash.index,  
type: this.config.logstash.type,  
body: {  
fields: ['@timestamp'],  
size: 1,  
sort: [  
{  
'@timestamp': 'desc'  
}  
],

so i get that request:

```
Elasticsearch DEBUG: 2016-12-01T14:23:35Z

```

starting request { method: 'POST',  
path: '/%3Clogstash-stats-short-%7Bnow%2Fd%7D%3E/json/\_search',  
body:  
{ fields: ['@timestamp'],  
size: 1,  
sort: [[Object] ],  
query: { filtered: [Object] } },  
query: {} }

but only Bad Request as response

---

<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:** [December 29, 2016, 2:25pm UTC](https://discuss.elastic.co/t/elasticsearch-js-and-index-date-math/67775/2 "2016-12-29T14:25:01Z")

</div>

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