# Using a variable from data to create/select indexes

**URL:** <https://discuss.elastic.co/t/using-a-variable-from-data-to-create-select-indexes/37117>\
**Category:** Elasticsearch\
**Created:** [December 14, 2015, 11:31am UTC](https://discuss.elastic.co/t/using-a-variable-from-data-to-create-select-indexes/37117 "2015-12-14T11:31:45Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![mattjayking](https://avatars.discourse-cdn.com/v4/letter/m/ecd19e/32.png) [@mattjayking](https://discuss.elastic.co/u/mattjayking)\
**Post date:** [December 14, 2015, 11:31am UTC](https://discuss.elastic.co/t/using-a-variable-from-data-to-create-select-indexes/37117/1 "2015-12-14T11:31:46Z")

</div>

Hello, I am using the ELK stack to parse and index log files and am currently trying to configure the way the data is indexed.

I currently have a piece of code that looks like this:  
(the spacing has been reformatted to fit the message)

curl -XPUT 'URL' -d '{  
"trigger" : { "schedule" : { "interval" : "10s" } },  
"input" : {  
"search" : {  
"request" : {  
"indices" : ["edge2016"],  
"body" : {  
"query" : {  
"bool" : {  
"must" : [  
{ "match" : {"message": "ORA600" } },  
]  
}  
}  
}  
}  
}  
},  
"condition" : {  
"compare" : { "ctx.payload.hits.total" : { "gt" : 0 }}  
},  
"actions" : {  
"index\_payload" : {  
"index" : {  
"index" : “HARD CODED CUSTOMER NAME",  
"doc\_type" : "my-type"  
}  
}  
}  
}’

I would like to be able to use a variable from the data to set the index.  
So it would look something like this:  
"index" : {  
"index" : "variable from data field $CustomerName",  
}

Is this at all possible?

* * *

Many Thanks,

Matt

---

<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, 11:31pm UTC](https://discuss.elastic.co/t/using-a-variable-from-data-to-create-select-indexes/37117/2 "2017-07-05T23:31:19Z")

</div>

Closed on July 5, 2017, 11:31pm UTC


