本文整理匯總了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);
}
示例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);
}
示例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);
}
示例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());
}