当前位置: 首页>>代码示例>>Java>>正文


Java DeleteQuery类代码示例

本文整理汇总了Java中org.springframework.data.elasticsearch.core.query.DeleteQuery的典型用法代码示例。如果您正苦于以下问题:Java DeleteQuery类的具体用法?Java DeleteQuery怎么用?Java DeleteQuery使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


DeleteQuery类属于org.springframework.data.elasticsearch.core.query包,在下文中一共展示了DeleteQuery类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: deleteObjectsOfAsset

import org.springframework.data.elasticsearch.core.query.DeleteQuery; //导入依赖的package包/类
@Override
public void deleteObjectsOfAsset(String assetId) {
    final HasParentQueryBuilder hasParentQuery =
            QueryBuilders.hasParentQuery(Asset.TYPE, QueryBuilders.matchQuery("id", assetId));

    final List<String> assetObjectIds = elasticsearchTemplate.queryForIds(new NativeSearchQuery(hasParentQuery));
    for (String assetObjectId : assetObjectIds) {
        try {
            Files.delete(storagePath.resolve(filenameFromId(assetObjectId)));
        } catch (IOException e) {
            LOG.warn("Unable to delete file of asset object {}", assetObjectId, e);
        }
    }

    final DeleteQuery deleteQuery = new DeleteQuery();
    deleteQuery.setQuery(hasParentQuery);
    elasticsearchTemplate.delete(deleteQuery, Asset.class);
}
 
开发者ID:moorkop,项目名称:mccy-engine,代码行数:19,代码来源:AssetObjectServiceImpl.java

示例2: deleteByQuery

import org.springframework.data.elasticsearch.core.query.DeleteQuery; //导入依赖的package包/类
@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
public void deleteByQuery(QueryBuilder query , Class type) {
	DeleteQuery deleteQuery = new DeleteQuery();
   	deleteQuery.setQuery(query);
	elasticsearchTemplate.delete(deleteQuery, type);
	elasticsearchTemplate.refresh(type, false);
}
 
开发者ID:uckefu,项目名称:uckefu,代码行数:9,代码来源:UKeFuRepositoryImpl.java

示例3: testForElasticsearchTemplate

import org.springframework.data.elasticsearch.core.query.DeleteQuery; //导入依赖的package包/类
@Test
public void testForElasticsearchTemplate() throws Exception {
    DeleteQuery deleteQuery = new DeleteQuery();
    deleteQuery.setQuery(QueryBuilders.idsQuery().addIds("id1","id2"));
    deleteQuery.setIndex("index");
    deleteQuery.setType("type");
    elasticsearchTemplate.delete(deleteQuery);
}
 
开发者ID:felayman,项目名称:elasticsearch-full,代码行数:9,代码来源:DeleteDemo.java

示例4: testDeleteObjectsOfAsset

import org.springframework.data.elasticsearch.core.query.DeleteQuery; //导入依赖的package包/类
@Test
public void testDeleteObjectsOfAsset() throws Exception {

    final File objFile = new File(storageDir, "file-1.dat");
    assertTrue(objFile.createNewFile());

    when(elasticsearchTemplate.queryForIds(any()))
            .thenReturn(Collections.singletonList("file-1"));

    assetObjectService.deleteObjectsOfAsset("parent-1");

    verify(elasticsearchTemplate).queryForIds(any());
    verify(elasticsearchTemplate).delete(any(DeleteQuery.class), eq(Asset.class));

    assertFalse(objFile.exists());
}
 
开发者ID:moorkop,项目名称:mccy-engine,代码行数:17,代码来源:AssetObjectServiceImplTest.java


注:本文中的org.springframework.data.elasticsearch.core.query.DeleteQuery类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。