I've made my own model for my application so I've began to set the content of the initMapping() function but I encountered a silly problem. The model is based on the following structure (I deleted useless data) :
and I don't know how to init the mapping by knowing that :
details contains a list of objects indexed by fullyear like details { "2016": {...}, "2015": {...} }
months contains a list of objects indexed by month index like months { "01": {...}, "02": {...}, ... }
weeks contains a list of objects indexed by week index like weeks { "01": {...}, "02": {...}, ... }
days contains a list of objects indexed by day index like days { "01": {...}, "02": {...}, ... }
At the beginning, I wanted to use the nested type but I don't want to have to repeat the model for each year ... I surely failed reading the documentation but at least, I have to admit that I tried before bothering you.
I don't know if I'm clear. don't hesitate if I wasn't enough.
I edited the json example in your post so its easier to read for others. Regarding your question, I'm not sure I get why you need that deep level of nesting to essentially represent a date and value. Is this structure imposed on you by your application? On the elastic search side I would try to flatten the data as much as possible, for example if you index time based events with a value foo I'd try to model it as
{
"event_time" : "2016-01-01",
"foo" : 258
}
and the mapping for this kind of data would be Date and an Integer. But maybe I'm missunderstanding your problem, in that case can you try to rephrase your question?
Thanks @cbuescher for your answer and for the json.
That's right that my application needs some explanations. It's a KPI application which works in two steps. The first one is like a simple dashboard to display some data like the revenue since the creation of the company or even how much orders has been made. Something classical so.
The second is the reason of my "complicated" json. The user have to be able to filter from a beginning date to an ending one. In this interval, I need to calculate data. The filter can be on a single day, and that's why I need to have each day. But if the filter has an interval running on two weeks, to avoid too much calculs, I use "global" vars like you could see here :
At the beginning of the project, I was thinking about using your way, with dates but it wouldn't be performant enough due to all the calculs that need to be done.
This solution is much simpler. The mapping is now about nested objects. However, I know, calculations will be more greedy because I should be doing loops in my objects.
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.