Service service = Service.connect(command.opts);
// Check the syntax of the query.
try {
Args parseArgs = new Args("parse_only", true);
service.parse(query, parseArgs);
}
catch (HttpException e) {
String detail = e.getDetail();
Command.error("query '%s' is invalid: %s", query, detail);
}
// Create the oneshot search query & query arguments.
Args queryArgs = new Args();
if (earliestTime != null)
queryArgs.put("earliest_time", earliestTime);
if (fieldList != null)
queryArgs.put("field_list", fieldList);
if (latestTime != null)
queryArgs.put("latest_time", latestTime);
if (statusBuckets > 0)
queryArgs.put("status_buckets", statusBuckets);
queryArgs.put("output_mode", outputMode);
// Execute the oneshot query, which returns the stream (i.e. there is
// no search job created, just a one time search)
InputStream stream = service.oneshotSearch(query, queryArgs);