Ejemplo n.º 1
0
  private void InitTasks() throws Exception {
    QueryBuilder builder = QueryBuilders.boolQuery().must(QueryBuilders.termQuery("_id", "_meta"));

    SearchRequestBuilder search = client.prepareSearch("_river");
    search.setTypes(river.riverName().name());
    search.setQuery(builder);
    SearchResponse resp = search.execute().actionGet();

    int hitCount = 0;
    for (SearchHit hit : resp.hits().getHits()) {
      logger.info(
          "Task Manager: Query response hits[ "
              + Integer.toString(hitCount)
              + "]: "
              + hit.sourceAsString());
      hitCount++;

      Map<String, Object> sourceMap = hit.sourceAsMap();
      Map<String, Object> my = (Map<String, Object>) sourceMap.get("my");
      ArrayList arr = (ArrayList) my.get("tasks");
      for (Object taskObj : arr) {
        Task newTask = new Task((Map<String, String>) taskObj, client, river.riverName().name());
        taskArr.add(newTask);
        taskMap.put(newTask.id(), newTask);
      }
    }

    currentTaskIndex = 0;
    currentTask = (Task) taskArr.get(currentTaskIndex);
  }
Ejemplo n.º 2
0
 public SearchResponse query(QueryBuilder queryBuilder) {
   SearchRequestBuilder srb = createSearchBuilder();
   srb.setQuery(queryBuilder);
   return srb.execute().actionGet();
 }