本文整理汇总了Java中com.google.appengine.api.search.Index.delete方法的典型用法代码示例。如果您正苦于以下问题:Java Index.delete方法的具体用法?Java Index.delete怎么用?Java Index.delete使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.appengine.api.search.Index
的用法示例。
在下文中一共展示了Index.delete方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: removeAll
import com.google.appengine.api.search.Index; //导入方法依赖的package包/类
protected int removeAll() {
int count = 0;
Index index = getIndex();
GetRequest request = GetRequest.newBuilder().setReturningIdsOnly(true).setLimit(200).build();
GetResponse<Document> response = index.getRange(request);
// can only deleteUnit documents in blocks of 200 so we need to iterate until they're all gone
while (!response.getResults().isEmpty()) {
List<String> ids = new ArrayList<>();
for (Document document : response) {
ids.add(document.getId());
}
index.delete(ids);
count += ids.size();
response = index.getRange(request);
}
return count;
}
示例2: removeAllDocumentsFromIndex
import com.google.appengine.api.search.Index; //导入方法依赖的package包/类
/**
* Cleans the index of places from all entries.
*/
private void removeAllDocumentsFromIndex() {
Index index = PlacesHelper.getIndex();
// As the request will only return up to 1000 documents,
// we need to loop until there are no more documents in the index.
// We batch delete 1000 documents per iteration.
final int numberOfDocuments = 1000;
while (true) {
GetRequest request = GetRequest.newBuilder()
.setReturningIdsOnly(true)
.build();
ArrayList<String> documentIds = new ArrayList<>(numberOfDocuments);
GetResponse<Document> response = index.getRange(request);
for (Document document : response.getResults()) {
documentIds.add(document.getId());
}
if (documentIds.size() == 0) {
break;
}
index.delete(documentIds);
}
}
示例3: unIndexApp
import com.google.appengine.api.search.Index; //导入方法依赖的package包/类
/**
* unindex gallery app from search index
* @param galleryId gallery id
*/
public void unIndexApp(long galleryId) {
Index index = getIndex();
try {
index.delete(String.valueOf(galleryId));
} catch (DeleteException e) {
LOG.info("error deleting index entry");
}
}
示例4: deletePackage
import com.google.appengine.api.search.Index; //导入方法依赖的package包/类
/**
* Deletes a package
*
* @param ofy Objectify
* @param name package name
*/
public static void deletePackage(Objectify ofy, String name) {
Package p = ofy.get(new Key<Package>(Package.class, name));
ofy.delete(p);
QueryResultIterable<Key<PackageVersion>> k =
ofy.query(PackageVersion.class).filter("package_ =", name)
.fetchKeys();
ofy.delete(k);
NWUtils.decrementPackageNumber();
Index index = NWUtils.getIndex();
index.delete(p.name);
NWUtils.incDataVersion();
}
示例5: delDocs
import com.google.appengine.api.search.Index; //导入方法依赖的package包/类
protected void delDocs(Index index) throws InterruptedException {
List<String> dList = new ArrayList<>();
Results<ScoredDocument> found = searchDocs(index, "", 0);
for (ScoredDocument document : found) {
dList.add(document.getId());
}
index.delete(dList);
sync();
}
示例6: testPutDeleteDocs
import com.google.appengine.api.search.Index; //导入方法依赖的package包/类
@Test
public void testPutDeleteDocs() throws InterruptedException {
String indexName = "put-index";
String docId = "testPutDocs";
List<String> docIdList = new ArrayList<>();
Index index = searchService.getIndex(IndexSpec.newBuilder()
.setName(indexName)
.build());
Field field = Field.newBuilder().setName("subject").setText("put(Document.Builder)").build();
Document.Builder docBuilder = Document.newBuilder()
.setId(docId + "1")
.addField(field);
index.put(docBuilder);
docIdList.add(docId + "1");
field = Field.newBuilder().setName("subject").setText("put(Document)").build();
Document document = Document.newBuilder()
.setId(docId + "2")
.addField(field).build();
index.put(document);
docIdList.add(docId + "1");
GetIndexesRequest request = GetIndexesRequest.newBuilder()
.setIndexNamePrefix(indexName)
.build();
GetResponse<Index> response = searchService.getIndexes(request);
List<Index> listIndexes = response.getResults();
for (Index oneIndex : listIndexes) {
Field retField = oneIndex.get(docId + "1").getOnlyField("subject");
assertEquals("put(Document.Builder)", retField.getText());
retField = oneIndex.get(docId + "2").getOnlyField("subject");
assertEquals("put(Document)", retField.getText());
oneIndex.delete(docIdList.get(0));
sync();
assertNull(oneIndex.get(docIdList.get(0)));
}
}
示例7: removeAllDocumentsFromIndex
import com.google.appengine.api.search.Index; //导入方法依赖的package包/类
private void removeAllDocumentsFromIndex() {
Index index = PlacesHelper.getIndex();
GetRequest request = GetRequest.newBuilder().setReturningIdsOnly(true).build();
GetResponse<Document> response = index.getRange(request);
for (Document document : response.getResults()) {
index.delete(document.getId());
}
}
开发者ID:googlearchive,项目名称:solutions-mobile-shopping-assistant-backend-java,代码行数:11,代码来源:MaintenanceTasksServlet.java