client.admin().indices().prepareFlush("test").setFull(true).execute().actionGet();
System.out.println("done");
}
static TimeValue timeQueries(Client client, String lang, String script, int numQueries) {
ScriptSortBuilder sort = SortBuilders.scriptSort(script, "number").lang(lang);
SearchRequestBuilder req = client.prepareSearch(indexName)
.setQuery(QueryBuilders.matchAllQuery())
.addSort(sort);
StopWatch timer = new StopWatch();