當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。