Running queries created by Kibana using Java API?

Is it feasible to run queries created by Kibana using Java API? I mean get a ready queries from Kibana dashboards that are created by users dynamically, and pass like a parameter in Java ?

this is an example of a query coming from Kibana dashboards :

{
"size": 0,
"query": {
"filtered": {
"query": {
"query_string": {
"analyze_wildcard": true,
"query": "*"
}
},
"filter": {
"bool": {
"must": [
{
"range": {
"@timestamp": {
"gte": 1274879129857,
"lte": 1432645529858
}
}
}
],
"must_not": []
}
}
}
},
"aggs": {
"3": {
"terms": {
"field": "ruleid",
"size": 20,
"order": {
"_count": "desc"
}
}
}
}
}r

Sure is. The KB queries are the same as any other that are passed to to ES.

1 Like

Thank you for your answer, but how can i do it in java API with this query, i mean the same ?

https://www.elastic.co/guide/en/elasticsearch/client/java-api/current/search.html

Check the example in the link above.

It is building up a query using a fluent style API. You will see the query built by QueryBuilders and filter built by FilterBuilders also using a fluent style api.

The other option of course is to use a java http client with the JSON you got from Kibana. Of course, then you have to parse the response yourself so I wouldn't suggest this necessarily over the first option.