I have the following data in Elasticsearch.(Since data is a little bit long, I've attached it at the bottom.) I am trying to figure out how to query in order to show something on a graph in Grafana.
I know my data in elasticsearch is not suitable for graphs, but I don't have any other sample data, and I just want to learn how to work this query. I've done something like this with mysql and grafana. (The data wasn't suitable for a graph, but I managed to make it like the below image)
I want to do the above with Elasticsearch. Since they use Lucene query(different from Mysql), I read some information on that. But I have no clues on what to put where. I want to show maybe metascore, or votes (please look at the Json at the bottom) on a graph.
I used Postman.
Here is the JSON type data. (I want to use 'votes' or 'metascore' to appear on the graph)
{
"took": 113,
"timed_out": false,
"_shards": {
"total": 1,
"successful": 1,
"skipped": 0,
"failed": 0
},
"hits": {
"total": {
"value": 8,
"relation": "eq"
},
"max_score": 1,
"hits": [
{
"_index": "movies",
"_type": "movie",
"_id": "dzb6AGoBnuCYnlTWZNmc",
"_score": 1,
"_source": {
"name": "Justice League",
"genre": "Action",
"summary": "Fueled by his restored faith in humanity and inspired by Superman's selfless act, Bruce Wayne enlists the help of his newfound ally, Diana Prince, to face an even greater enemy",
"yearofrelease": 201,
"metascore": 45,
"votes": 275122,
"rating": 6.6
}
},
{
"_index": "movies",
"_type": "movie",
"_id": "1",
"_score": 1,
"_source": {
"name": "Justice League1",
"genre": "Action1",
"summary": "Fueled by his restored faith in humanity and inspired by Superman's selfless act, Bruce Wayne enlists the help of his newfound ally, Diana Prince, to face an even greater enemy",
"yearofrelease": 201,
"metascore": 45,
"votes": 275122,
"rating": 6.6
}
},
{
"_index": "movies",
"_type": "movie",
"_id": "2",
"_score": 1,
"_source": {
"name": "Justice League",
"genre": "Action",
"summary": "Fueled by his restored faith in humanity and inspired by Superman's selfless act, Bruce Wayne enlists the help of his newfound ally, Diana Prince, to face an even greater enemy",
"yearofrelease": 2011,
"metascore": 45,
"votes": 275122,
"rating": 6.6
}
},
{
"_index": "movies",
"_type": "movie",
"_id": "hDYYAWoBnuCYnlTWyNmZ",
"_score": 1,
"_source": {
"name": "Thor Ragnarok",
"genre": "Action",
"summary": "Thor is imprisoned on the planet Sakaar, and must race against time to return to Asgard and stop Ragnarök, the destruction of his world, at the hands of the powerful and ruthless villain Hela",
"yearofrelease": 2017,
"metascore": 74,
"votes": 374270,
"rating": 7.9
}
},
{
"_index": "movies",
"_type": "movie",
"_id": "hTYYAWoBnuCYnlTWyNmZ",
"_score": 1,
"_source": {
"name": "Infinity War",
"genre": "Sci-Fi",
"summary": "The Avengers and their allies must be willing to sacrifice all in an attempt to defeat the powerful Thanos before his blitz of devastation and ruin puts an end to the universe",
"yearofrelease": 2018,
"metascore": 68,
"votes": 450856,
"rating": 8.6
}
},
{
"_index": "movies",
"_type": "movie",
"_id": "hzYYAWoBnuCYnlTW-9mV",
"_score": 1,
"_source": {
"name": "Thor Ragnarok",
"genre": "Action",
"summary": "Thor is imprisoned on the planet Sakaar, and must race against time to return to Asgard and stop Ragnarök, the destruction of his world, at the hands of the powerful and ruthless villain Hela",
"yearofrelease": 2017,
"metascore": 74,
"votes": 374270,
"rating": 7.9
}
},
{
"_index": "movies",
"_type": "movie",
"_id": "iDYYAWoBnuCYnlTW-9mV",
"_score": 1,
"_source": {
"name": "Infinity War",
"genre": "Sci-Fi",
"summary": "The Avengers and their allies must be willing to sacrifice all in an attempt to defeat the powerful Thanos before his blitz of devastation and ruin puts an end to the universe",
"yearofrelease": 2018,
"metascore": 68,
"votes": 450856,
"rating": 8.6
}
},
{
"_index": "movies",
"_type": "movie",
"_id": "iTYYAWoBnuCYnlTW-9mV",
"_score": 1,
"_source": {
"name": "Christopher Robin",
"genre": "Comedy",
"summary": "A working-class family man, Christopher Robin, encounters his childhood friend Winnie-the-Pooh, who helps him to rediscover the joys of life",
"yearofrelease": 2018,
"metascore": 60,
"votes": 9648,
"rating": 7.9
}
}
]
}
}
If this data is impossible to be displayed on a graph, then could you give me some tips on what I can put in the query and metric fields below so that I can work this when I have other sample data. I need an example like 'metascore' should go in this field, and you need @ or _ and put index here, and type there, etc)