Hi everyone! First of all, I apologize for my bad english.
Now, the question! I'm new to Elastic and I'm following the online guide, but I still have a few unsolved doubts:
-
I have two different indexes: "jobs" and "stops" (data of a profiling machine).
-
Both indexes have begin/end DateTime fields, but those fields have different names ("jobs_date_begin", jobs_date_end" & "stops_date_begin", "stops_date_end").
-
Now I want to extract some data: every "job" might have one or more "stops" included in its DateTime range.
-
So, the query I need to do is something like this: [foreach record in "jobs" find me every record in "stops" whose "stops_date_begin" is included in DateTime range of "jobs_date_begin" & "jobs_date_end"]. Basically I need to perform a "Join" between JOBS and STOPS indexes based on the overlapping of these dates
-
How can I obtain this kind of result? I need a complex query? Or a script? Or what? I expect the result to be a JSON with a structure as follows (or something similar)
[
{
"name": "Job1"
"jobs_date_begin": "2016-02-07-10:15:00"
"jobs_date_stop": "2016-02-07-12:22:00"
"stops:"[
{
"stop_name": "Stop23",
"stops_date_begin": "2016-02-07-11:12:00",
"stops_date_end": "2016-02-07-11:14:00",
},
{
"stop_name": "Stop32",
"stops_date_begin": "2016-02-07-11:33:00",
"stops_date_end": "2016-02-07-11:38:00",
},
]
},
etc, other jobs will follow with the same structure
]
-
In order to achieve such result, is my data structure (two differents indexes) correct? Is a change of structure required?
-
I know I'm on the wrong forum, but (if it's possible to accomplish what I wrote before), how can I use this JSON result in Kibana in order to get an histogram?. Moreover is it possible to use this same JSON to build more complex histograms which perform some kind of aggregation on such data?
I attach a paint demo of the histogram needed (a vertical histogram with X_Axis="job_id" and Y_Axis="stops_count").
Thank you very much,
Max