-
Notifications
You must be signed in to change notification settings - Fork 8.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Json aggs #1760
Json aggs #1760
Conversation
watch for the resolution of the promise repsonse to check to classes on the directive
Looks like the json editor only shows up when the agg already has advanced params. Should show up on all aggs. |
Besides previous comment 👍 |
@spenceralger advanced wasn't being shown because it wasn't always in the params (it was only in terms). The latest commit always appends the JSON type to all param types. |
I new to Kibana so maybe my assumption is wrong. I am trying to somehow use But in reality, the json was added into the sum aggregation (I extracted this query from the error report): {
"query": {
"filtered": {
"query": {
"query_string": {
"query": "*"
}
},
"filter": {
"bool": {
"must": [
{
"range": {
"mts": {
"gte": 1418767200000,
"lte": 1418987718938
}
}
}
],
"must_not": []
}
}
}
},
"size": 0,
"aggs": {
"2": {
"date_histogram": {
"field": "mts",
"interval": "3600000ms",
"min_doc_count": 1,
"extended_bounds": {
"min": 1418767200000,
"max": 1418987718936
}
},
"aggs": {
"1": {
"sum": {
"field": "M8000C0",
"aggs": {
"kpi1": {
"scripted_metric": {
"init_script": "_agg. sumVal1 = 0; _agg.sumVal2 = 0;",
"map_script": "_agg.sumVal1 += doc.val1; _agg.sumVal2 += doc.val2;",
"reduce_script": "totalVal1 = 0; totalVal2 = 0; for (agg in _aggs) { totalVal1 += agg.sumVal1; totalVal2 += agg.sumVal2;}; return totalVal2/ totalVal1"
}
}
}
}
}
}
}
},
"fields": [
"*",
"_source"
],
"script_fields": {
"mts": {
"script": "if (doc['mts'].value == 0) { null } else { doc['mts'].value }"
}
}
} Is this an error in my assumptions about the json actually replacing the aggregation or is this some edge case not covered? |
I have a similar problem trying to visualise the query of the following exemple in Kibana: http://www.elasticsearch.org/guide/en/elasticsearch/guide/current/children-agg.html I add a term aggregation with the country field and then try to add the children aggregation using the JSON Input area: The JSON is not added in the expected place: Is it a bug or an incorrect use of the JSON Input area? Thank a lot!! |
Hey @tomercagan @jvienne I think you misunderstood the purpose of the JSON input in the agg builder; it is for defining or overriding parameters/arguments for a specific aggregation. It can not add arbitrary aggregations to the visualization. This is likely to always be the case, as we need to know what an aggregation does in order to read it's results, use its results to create bars/slices/lines/etc, format the values it produces, and label the visual elements it creates. Sorry for the confusion!! Maybe we could describe the capabilities of this input a bit better in the UI. |
Hi @spenceralger - thanks for the response. I am not sure about children aggregation but it seems to me that metric aggregation is very similar to any "arithmetic" aggregation - it results in one value per bucket (though this value could be an object). Thanks! |
@tomercagan no problem. Currently there isn't any way to do that but we are investigating adding the top hits agg once #1536 is complete. Maybe the "children" agg will come around that time. |
@spenceralger thanks for your answer! There is no way to visualise a children aggregation? |
Correct |
Closes #1731
This had become a larger project than expected, partly because I started going about it the wrong way and created tests along the way for parts that weren't really related. But, at least more things have tests now...
This PR adds a JSON input to the agg builder. The intention is that you can take a JSON ES query from elsewhere, drop it in this input, and get the results in Kibana without having to build it by hand.
Note: Any JSON data put in this input will clobber input from any other fields in the agg builder.
raw_json
param type and control, with tests (100%)query_input
component is now thevalidate_query
directive, with tests (78%)debounce
service created, with tests (100%), andvalidate_query
uses it instead of_.debounce
input-error
css class was abstracted out, with hopes to re-use it elsewhere (now in_input.less
)validate_json
directive was added, with tests (100%)