org.elasticsearch.client.Client.prepareDeleteByQuery()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(4.7k)|赞(0)|评价(0)|浏览(142)

本文整理了Java中org.elasticsearch.client.Client.prepareDeleteByQuery()方法的一些代码示例,展示了Client.prepareDeleteByQuery()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Client.prepareDeleteByQuery()方法的具体详情如下:
包路径:org.elasticsearch.client.Client
类名称:Client
方法名:prepareDeleteByQuery

Client.prepareDeleteByQuery介绍

暂无

代码示例

代码示例来源:origin: apache/usergrid

/**
 * Completely delete an index.
 */
public Observable deleteApplication() {
  String idString = applicationId(applicationScope.getApplication());
  final TermQueryBuilder tqb = QueryBuilders.termQuery(APPLICATION_ID_FIELDNAME, idString);
  final String[] indexes = getIndexes();
  //Added For Graphite Metrics
  return Observable.from( indexes ).flatMap( index -> {
    final ListenableActionFuture<DeleteByQueryResponse> response =
      esProvider.getClient().prepareDeleteByQuery( alias.getWriteAlias() ).setQuery( tqb ).execute();
    response.addListener( new ActionListener<DeleteByQueryResponse>() {
      @Override
      public void onResponse( DeleteByQueryResponse response ) {
        checkDeleteByQueryResponse( tqb, response );
      }
      @Override
      public void onFailure( Throwable e ) {
        logger.error( "Failed on delete index", e.getMessage() );
      }
    } );
    return Observable.from( response );
  } ).doOnError( t -> logger.error( "Failed on delete application", t.getMessage() ) );
}

代码示例来源:origin: uberVU/elasticsearch-river-github

private void deleteByType(String type) {
  client.prepareDeleteByQuery(index)
      .setQuery(termQuery("_type", type))
      .execute()
      .actionGet();
}

代码示例来源:origin: rmagen/elastic-gremlin

public static DeleteByQueryResponse clearIndex(Client client, String indexName){
  DeleteByQueryResponse indexDeleteByQueryResponses = client.prepareDeleteByQuery(indexName).setQuery(QueryBuilders.matchAllQuery()).execute().actionGet();
  GetMappingsResponse getMappingsResponse = client.admin().indices().prepareGetMappings(indexName).execute().actionGet();
  ArrayList<String> mappings = new ArrayList();
  getMappingsResponse.getMappings().forEach(map -> {
    map.value.forEach(map2 -> mappings.add(map2.value.type()));
  });
  if(mappings.size() > 0) {
    DeleteMappingResponse deleteMappingResponse = client.admin().indices().prepareDeleteMapping(indexName).setType(mappings.toArray(new String[mappings.size()])).execute().actionGet();
  }
  return indexDeleteByQueryResponses;
}

代码示例来源:origin: com.github.tlrx/elasticsearch-test

/**
 * Delete all documents in the index
 *
 * @param nodeName
 * @param indexName
 * @throws Exception
 * @throws ElasticsearchException
 */
private void clean(Map<String, Object> context, String nodeName, String indexName) throws ElasticsearchException, Exception {
  client(context, nodeName).prepareDeleteByQuery(indexName)
      .setQuery(QueryBuilders.matchAllQuery())
      .execute().actionGet();
}

代码示例来源:origin: org.sakaiproject.search.elasticsearch/elasticsearch-util

protected void deleteAllDocumentForSite(String siteId) {
  getLog().debug("removing all documents from search index for siteId: " + siteId);
  DeleteByQueryResponse response = client.prepareDeleteByQuery(indexName)
      .setQuery(termQuery(SearchService.FIELD_SITEID, siteId))
      .setTypes(indexedDocumentType)
      .execute()
      .actionGet();
}

代码示例来源:origin: tlrx/elasticsearch-test

/**
 * Delete all documents in the index
 *
 * @param nodeName
 * @param indexName
 * @throws Exception
 * @throws ElasticsearchException
 */
private void clean(Map<String, Object> context, String nodeName, String indexName) throws ElasticsearchException, Exception {
  client(context, nodeName).prepareDeleteByQuery(indexName)
      .setQuery(QueryBuilders.matchAllQuery())
      .execute().actionGet();
}

代码示例来源:origin: com.erudika/para

@Override
public void unindexAll(String appid, Map<String, ?> terms, boolean matchAll) {
  if (StringUtils.isBlank(appid) || terms == null || terms.isEmpty()) {
    return;
  }
  DeleteByQueryRequestBuilder dqrb = client().prepareDeleteByQuery(appid);
  dqrb.setQuery(QueryBuilders.filteredQuery(QueryBuilders.matchAllQuery(), getTermsFilter(terms, matchAll)));
  if (isAsyncEnabled()) {
    dqrb.execute();
  } else {
    dqrb.execute().actionGet();
  }
  logger.debug("Search.unindexAll() {}", terms.size());
}

代码示例来源:origin: SpringDataElasticsearchDevs/spring-data-elasticsearch

@Override
public <T> void delete(DeleteQuery deleteQuery, Class<T> clazz) {
  ElasticsearchPersistentEntity persistentEntity = getPersistentEntityFor(clazz);
  client.prepareDeleteByQuery(persistentEntity.getIndexName())
      .setTypes(persistentEntity.getIndexType())
      .setQuery(deleteQuery.getQuery())
      .execute().actionGet();
}

代码示例来源:origin: mallocator/Elasticsearch-MySQL-River

if (MysqlRiver.this.deleteOldEntries) {
  MysqlRiver.this.logger.info("Removing old MySQL entries from ElasticSearch!");
  MysqlRiver.this.esClient.prepareDeleteByQuery(MysqlRiver.this.index)
    .setTypes(MysqlRiver.this.type)
    .setQuery(QueryBuilders.rangeQuery("_timestamp").lt(timestamp))

代码示例来源:origin: alien4cloud/alien4cloud

esClient.prepareDeleteByQuery(new String[] { index }).setQuery(QueryBuilders.matchAllQuery()).execute().get();

相关文章