private void deleteKeys(List<ActiveRuleKey> keys) {
   BulkIndexer bulk = new BulkIndexer(esClient, INDEX);
   bulk.start();
   SearchRequestBuilder search =
       esClient
           .prepareSearch(INDEX)
           .setTypes(TYPE_ACTIVE_RULE)
           .setQuery(QueryBuilders.boolQuery().must(termsQuery(FIELD_ACTIVE_RULE_KEY, keys)));
   bulk.addDeletion(search);
   bulk.stop();
 }
 public void deleteProfile(String qualityProfileKey) {
   BulkIndexer bulk = new BulkIndexer(esClient, INDEX);
   bulk.start();
   SearchRequestBuilder search =
       esClient
           .prepareSearch(INDEX)
           .setTypes(TYPE_ACTIVE_RULE)
           .setQuery(
               QueryBuilders.boolQuery()
                   .must(termsQuery(FIELD_ACTIVE_RULE_PROFILE_KEY, qualityProfileKey)));
   bulk.addDeletion(search);
   bulk.stop();
 }
示例#3
0
 private static long doIndex(BulkIndexer bulk, Iterator<FileSourcesUpdaterHelper.Row> dbRows) {
   long maxUpdatedAt = 0L;
   bulk.start();
   while (dbRows.hasNext()) {
     FileSourcesUpdaterHelper.Row row = dbRows.next();
     for (UpdateRequest updateRequest : row.getUpdateRequests()) {
       bulk.add(updateRequest);
     }
     maxUpdatedAt = Math.max(maxUpdatedAt, row.getUpdatedAt());
   }
   bulk.stop();
   return maxUpdatedAt;
 }
  private static long doIndex(BulkIndexer bulk, Iterator<ActiveRuleDoc> activeRules) {
    bulk.start();
    long maxDate = 0L;
    while (activeRules.hasNext()) {
      ActiveRuleDoc activeRule = activeRules.next();
      bulk.add(newIndexRequest(activeRule));

      // it's more efficient to sort programmatically than in SQL on some databases (MySQL for
      // instance)
      maxDate = Math.max(maxDate, activeRule.updatedAt());
    }
    bulk.stop();
    return maxDate;
  }
示例#5
0
 /**
  * Delete all the documents matching the given search request. This method is blocking. Index is
  * refreshed, so docs are not searchable as soon as method is executed.
  *
  * <p>Note that the parameter indexName could be removed if progress logs are not needed.
  */
 public static void delete(EsClient client, String indexName, SearchRequestBuilder searchRequest) {
   BulkIndexer bulk = new BulkIndexer(client, indexName);
   bulk.start();
   bulk.addDeletion(searchRequest);
   bulk.stop();
 }