How to efficiently query date *and* type based indexes

Our environment has one large monolythic index that is 483 million docs with a size of 1TB. This is currently spread over 23 shards. As it grows, we keep needing to scale out by reindexing into more shards. In this index, we have 23 types. Some of these types have only marginal overlap in common fields. We are currently on 2.3.2 and want to be able to upgrade, but ES is phasing out multiple types per index. Also, we would like to be able to break our data down by months to make querying and data-retention easier. To that end, I am looking at splitting up the index by both type and month. We would end up with, for example:


And so forth.

Note that this is not like logging data where we have an "open window" index to write to. Any document from any time can get updated. We can handle that in our indexing code.

Our UX has filters that allow you to specify (among many other things) a date range and types. I am realizing that if I was dealing with just one of these (i.e. type or date), it would be simple, but the combined scenario is what I am trying to wrap my head around.

For example, for types "abc," "aab", "cba" and "aaa," I could query with:




I could also create an alias that points to these indexes and search:


For dates, if I want all items in September and October of this year, I could do:


Or again, I could create an alias (which I would keep updated) that points to the last 2 months:


The problem is if I want to combine them. If I wanted a subset of types, for a specific date range, I would have to explicitly list out all the indexes without the aid of aliases. So for three types over two months, it would need to be


This easily gets unwieldy (and will probably exeed the character size allowed for a request.

I had hoped that date math in the index name would solve part of it (i.e. hoping that you could do a gte/lte logic), but it appears you can only use that to resolve a specific date.

Is there a good way to do this or are we crazy to take this approach?


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