I'm attempting to render a Google Chart based on an Elasticsearch query.
Here is my non-working code:
// Load the Visualization API and the piechart package.
google.load('visualization', '1', {'packages':['corechart']});
// Set a callback to run when the Google Visualization API is loaded.
google.setOnLoadCallback(drawChart);
function drawChart() {
var jsonData = $.ajax({
url: 'http://localhost:9200/inventory/_search?pretty=true'
, type: 'POST'
, data :
JSON.stringify(
{
"query" : { "match_all" : {} },
"facets" : {
"tags" : {
"terms" : {
"field" : "qty_onhand",
"size" : "10"
}
}
}
}),
dataType:"json"
async: false
,processData: false
}).responseText;
// Create our data table out of JSON data loaded from server.
var data = new google.visualization.DataTable(jsonData);
// Instantiate and draw our chart, passing in some options.
var chart = new
google.visualization.PieChart(document.getElementById('chart_div'));
chart.draw(data, {width: 400, height: 240});
}
</script>
The issue I'm running into is that the data returned from the query is not
the the "fields", but its the entire query summary, including:
{
- took: 10
- timed_out: false
- _shards: {
- total: 5
- successful: 5
- failed: 0
}
- hits: {
- total: 11
- max_score: 1
- hits: [
etc...
Is there a way to return this query while retaining only the fields? Or
perhaps there is a way to query and format the data in a PHP file that I
can then call in the chart?
--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.