1
votes

I have following record in my elastic search database.

  {
    "frd": "2017-06-30",
    "tim": "2017-01-19T11:02:21.847",
    "tpr": 2276.5
  },
  {
    "frd": "2017-06-29",
    "tim": "2017-01-19T11:02:21.847",
    "tpr": 2408.5
  },
  {
    "frd": "2017-06-28",
    "tim": "2017-01-20T12:01:08.358",
    "tpr": 2408.5
  },
  {
    "frd": "2017-06-30",
    "tim": "2017-01-20T12:01:08.358",
    "tpr": 2276.5
  },
  {
    "frd": "2017-06-30",
    "tim": "2017-01-20T17:35:17.495",
    "tpr": 2408.5
  },
  {
    "frd": "2017-06-30",
    "tim": "2017-01-19T10:04:44.586",
    "tpr": 2276.5
  },
  {
    "frd": "2017-06-30",
    "tim": "2017-01-19T10:15:46.051",
    "tpr": 2276.5
  }

Elastic version is 5. I am going to create a multi series line chart from above data set so I want to get a new json from above data as below.

[
  {
    "tim": "2017-01-19T11:02:21.847",
    "2017-06-28": null,
    "2017-06-29": 2408.5,
    "2017-06-30": 2276.5
  },
  {
    "tim": "2017-01-20T12:01:08.358",
    "2017-06-28": 2408.5,
    "2017-06-29": null,
    "2017-06-30": 2276.5
  },
  {
    "tim": "2017-01-20T17:35:17.495",
    "2017-06-28": null,
    "2017-06-29": null,
    "2017-06-30": 2408.5
  },
  {
    "tim": "2017-01-19T10:04:44.586",
    "2017-06-28": null,
    "2017-06-29": null,
    "2017-06-30": 2276.5
  },
  {
    "tim": "2017-01-19T10:15:46.051",
    "2017-06-28": null,
    "2017-06-29": null,
    "2017-06-30": 2276.5
  }
]

X axis becomes tim values. Y axis becomes tpr. Lines should be group by frd.

Is there a way to get above chart data set from elastic data with elastic search query?

Thank you

1
not sure if you can, but wouldn't the parser for this be easier to write/maintain rather than the complex query? - nafas
Can I do this with elastic search aggregation? - Rose18

1 Answers

0
votes

For visualising you can directly use Kibana (v5). There in you can make the line chart directly by selecting whatever fields you want to

Here is the link to User guide of Kibana 5.1