String outputMode = "xml";
if (command.opts.containsKey("output_mode"))
outputMode = (String)command.opts.get("output_mode");
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);
boolean rawData = true;
if (command.opts.containsKey("raw")) {
int tmp = (Integer)command.opts.get("raw");
if (tmp == 0 ) rawData = false;