I see two options.
You specify indexes when you search such as
GET /index-2016.04.10,index-2016.04.11,index-2016.04.12/_search?ignore_unavailable=true
{
"query": {
yourquery
}
}
Or Filter in query (But this approach could be slow, and depends on amount of indexes could throw shard exception, since you will query all indexes which match pattern)
GET /index-*/_search
{
"query": {
"terms" : {
"_index" : ["index1", "index2"]
}
}
}
I assume you will be indexing data in the past like last 7, 14, 30 days: so in this case i would definitely go with first approach, do index name calculation in your app
UPDATE 1: To prevent error for non existing indicies you can set flag ignore_unavailable
UPDATE 2:
Well i you need to do search in the past one of the solution could be haveing an agregation job.
In ES there is reindex api
POST _reindex
{
"source": {
"index": ["twitter", "blog"]
},
"dest": {
"index": "all_together"
}
}
You will have daily index up to 7 days. Then on Monday 0:0 you aggregate data to weekly index.
You will have weekly up to 5 indexes. Again last day of the month you reindex to monthly index.
In query you combine multiple approach by providing which indexes you want to search and query filter.