Search in sources :

Example 1 with BulkIndexer

use of org.sonar.server.es.BulkIndexer in project sonarqube by SonarSource.

the class ComponentIndexer method delete.

public void delete(String projectUuid, Collection<String> disabledComponentUuids) {
    BulkIndexer bulk = new BulkIndexer(esClient, INDEX_TYPE_COMPONENT.getIndex());
    bulk.start();
    disabledComponentUuids.stream().forEach(uuid -> bulk.addDeletion(INDEX_TYPE_COMPONENT, uuid, projectUuid));
    bulk.stop();
}
Also used : BulkIndexer(org.sonar.server.es.BulkIndexer)

Example 2 with BulkIndexer

use of org.sonar.server.es.BulkIndexer in project sonarqube by SonarSource.

the class IssueIndexer method deleteProject.

@Override
public void deleteProject(String uuid) {
    BulkIndexer bulk = new BulkIndexer(esClient, INDEX_TYPE_ISSUE.getIndex());
    bulk.start();
    SearchRequestBuilder search = esClient.prepareSearch(INDEX_TYPE_ISSUE).setRouting(uuid).setQuery(boolQuery().must(termQuery(FIELD_ISSUE_PROJECT_UUID, uuid)));
    bulk.addDeletion(search);
    bulk.stop();
}
Also used : SearchRequestBuilder(org.elasticsearch.action.search.SearchRequestBuilder) BulkIndexer(org.sonar.server.es.BulkIndexer)

Example 3 with BulkIndexer

use of org.sonar.server.es.BulkIndexer in project sonarqube by SonarSource.

the class RuleIndexer method createBulkIndexer.

private BulkIndexer createBulkIndexer(Size size) {
    BulkIndexer bulk = new BulkIndexer(esClient, INDEX_TYPE_RULE.getIndex());
    bulk.setSize(size);
    return bulk;
}
Also used : BulkIndexer(org.sonar.server.es.BulkIndexer)

Example 4 with BulkIndexer

use of org.sonar.server.es.BulkIndexer in project sonarqube by SonarSource.

the class ActiveRuleIndexer method deleteKeys.

private void deleteKeys(List<ActiveRuleKey> keys) {
    BulkIndexer bulk = new BulkIndexer(esClient, INDEX_TYPE_ACTIVE_RULE.getIndex());
    bulk.start();
    SearchRequestBuilder search = esClient.prepareSearch(INDEX_TYPE_ACTIVE_RULE).setQuery(QueryBuilders.boolQuery().must(termsQuery(FIELD_ACTIVE_RULE_KEY, keys)));
    bulk.addDeletion(search);
    bulk.stop();
}
Also used : SearchRequestBuilder(org.elasticsearch.action.search.SearchRequestBuilder) BulkIndexer(org.sonar.server.es.BulkIndexer)

Example 5 with BulkIndexer

use of org.sonar.server.es.BulkIndexer in project sonarqube by SonarSource.

the class ActiveRuleIndexer method deleteProfile.

public void deleteProfile(String qualityProfileKey) {
    BulkIndexer bulk = new BulkIndexer(esClient, INDEX_TYPE_ACTIVE_RULE.getIndex());
    bulk.start();
    SearchRequestBuilder search = esClient.prepareSearch(INDEX_TYPE_ACTIVE_RULE).setQuery(QueryBuilders.boolQuery().must(termsQuery(FIELD_ACTIVE_RULE_PROFILE_KEY, qualityProfileKey)));
    bulk.addDeletion(search);
    bulk.stop();
}
Also used : SearchRequestBuilder(org.elasticsearch.action.search.SearchRequestBuilder) BulkIndexer(org.sonar.server.es.BulkIndexer)

Aggregations

BulkIndexer (org.sonar.server.es.BulkIndexer)13 DbSession (org.sonar.db.DbSession)4 SearchRequestBuilder (org.elasticsearch.action.search.SearchRequestBuilder)3 Map (java.util.Map)2 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 Preconditions.checkArgument (com.google.common.base.Preconditions.checkArgument)1 Maps.newHashMap (com.google.common.collect.Maps.newHashMap)1 Arrays (java.util.Arrays)1 Collection (java.util.Collection)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Set (java.util.Set)1 Stream (java.util.stream.Stream)1 IndexRequest (org.elasticsearch.action.index.IndexRequest)1 DateUtils (org.sonar.api.utils.DateUtils)1 Collectors (org.sonar.core.util.stream.Collectors)1 Collectors.toSet (org.sonar.core.util.stream.Collectors.toSet)1 DbClient (org.sonar.db.DbClient)1 ComponentDto (org.sonar.db.component.ComponentDto)1 Size (org.sonar.server.es.BulkIndexer.Size)1