# Date in index name using sense

**URL:** <https://discuss.elastic.co/t/date-in-index-name-using-sense/48996>\
**Category:** Elasticsearch\
**Created:** [May 2, 2016, 8:20pm UTC](https://discuss.elastic.co/t/date-in-index-name-using-sense/48996 "2016-05-02T20:20:40Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![mc1392](https://avatars.discourse-cdn.com/v4/letter/m/57b2e6/32.png) [@mc1392](https://discuss.elastic.co/u/mc1392)\
**Post date:** [May 2, 2016, 8:20pm UTC](https://discuss.elastic.co/t/date-in-index-name-using-sense/48996/1 "2016-05-02T20:20:40Z")

</div>

How can I create a date based index using sense?

Here is what I usually do:

> PUT /member\_history/  
> {  
> "mappings": {  
> "ats\_member\_history": {  
> "dynamic\_templates": [  
> { "notanalyzed": {  
> "match": "\*",  
> "match\_mapping\_type": "string",  
> "mapping": {  
> "type": "string",  
> "index": "not\_analyzed"  
> }  
> }  
> }  
> ]  
> }  
> }  
> }

I tried this, but I get naming exception:

> PUT /member\_history-\*/  
> {  
> .......

And this definitely doesn't work:

> PUT /member\_history-[YYYY.MM.dd]/  
> {  
> ......

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [May 2, 2016, 9:01pm UTC](https://discuss.elastic.co/t/date-in-index-name-using-sense/48996/2 "2016-05-02T21:01:45Z")

</div>

When something like Logstash does it, it passes in the actual date. You need to do the same, it can't figure it out automatically.

It might be a worthy FR though!

---

<div class="post-metadata">

**Author:** ![mc1392](https://avatars.discourse-cdn.com/v4/letter/m/57b2e6/32.png) [@mc1392](https://discuss.elastic.co/u/mc1392)\
**Post date:** [May 3, 2016, 2:01pm UTC](https://discuss.elastic.co/t/date-in-index-name-using-sense/48996/3 "2016-05-03T14:01:49Z")

</div>

When I do this, my index keeps getting renamed to logstash-YYYY.MM.dd (today that would be 2016.05.03).  
I am at least able to get raw fields.

**My JSON template**  
\> {  
\> "template": "member\_type\_history\_template",  
\> "mappings": {  
\> "string\_fields": {  
\> "match": "\*",  
\> "match\_mapping\_type": "string",  
\> "mapping": {  
\> "type": "string",  
\> "index": "not\_analyzed"  
\> }  
\> }  
\> }  
\> }

**My logstash output:**

> output{

> ```
> elasticsearch {
> #index=>"member_type_history-%{+YYYY.MM.dd}"
> hosts => ["localhost:9200"]
> template => "/home/ubuntu/template/member_type_history_template.json"
> template_name => "member_type_history_template"
> template_overwrite => true
> 
> ```

> ```
> }
> 
> ```

> stdout { codec =\> json }

> }

---

<div class="post-metadata">

**Author:** ![mc1392](https://avatars.discourse-cdn.com/v4/letter/m/57b2e6/32.png) [@mc1392](https://discuss.elastic.co/u/mc1392)\
**Post date:** [May 3, 2016, 3:43pm UTC](https://discuss.elastic.co/t/date-in-index-name-using-sense/48996/4 "2016-05-03T15:43:43Z")

</div>

I think I am going crazy.  
The above mapping isnt working anymore.

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [May 3, 2016, 8:57pm UTC](https://discuss.elastic.co/t/date-in-index-name-using-sense/48996/5 "2016-05-03T20:57:28Z")

</div>

LS translates `%{+YYYY.MM.dd}` into an actual date before it passes it to ES, that's why.

---

<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:** [July 5, 2017, 10:54pm UTC](https://discuss.elastic.co/t/date-in-index-name-using-sense/48996/6 "2017-07-05T22:54:15Z")

</div>


