• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java GetRequest类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



GetRequest类属于com.google.appengine.api.search包,在下文中一共展示了GetRequest类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: removeAll

import com.google.appengine.api.search.GetRequest; //导入依赖的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;
}
 
开发者ID:monPlan,项目名称:springboot-spwa-gae-demo,代码行数:19,代码来源:BaseGaeSearchService.java


示例2: clear

import com.google.appengine.api.search.GetRequest; //导入依赖的package包/类
@Override
public <E> int clear(Class<E> entityClass) {
    Index index = getIndex(entityClass);

    GetRequest request = GetRequest.newBuilder()
            .setReturningIdsOnly(true)
            .setLimit(200) //Delete only allows 200 records at a time.
            .build();

    int count = 0;
    for (List<Document> documents = getDocumentIds(index, request); !documents.isEmpty(); documents = getDocumentIds(index, request)) {
        count += documents.size();
        unindex(entityClass, documents.stream().map(Document::getId));
    }
    return count;
}
 
开发者ID:n15g,项目名称:spring-boot-gae,代码行数:17,代码来源:SearchServiceImpl.java


示例3: removeAllDocumentsFromIndex

import com.google.appengine.api.search.GetRequest; //导入依赖的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);
    }
}
 
开发者ID:googlearchive,项目名称:MobileShoppingAssistant-sample,代码行数:28,代码来源:MaintenanceTasksServlet.java


示例4: doGet

import com.google.appengine.api.search.GetRequest; //导入依赖的package包/类
@Override
public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException {
  PrintWriter out = resp.getWriter();
  Document document = Document.newBuilder()
      .setId("AZ125")
      .addField(Field.newBuilder().setName("myField").setText("myValue")).build();
  try {
    Utils.indexADocument(INDEX, document);
  } catch (InterruptedException e) {
    out.println("Interrupted");
    return;
  }
  out.println("Indexed a new document.");
  // [START get_document]
  IndexSpec indexSpec = IndexSpec.newBuilder().setName(INDEX).build();
  Index index = SearchServiceFactory.getSearchService().getIndex(indexSpec);

  // Fetch a single document by its  doc_id
  Document doc = index.get("AZ125");

  // Fetch a range of documents by their doc_ids
  GetResponse<Document> docs = index.getRange(
      GetRequest.newBuilder().setStartId("AZ125").setLimit(100).build());
  // [END get_document]
  out.println("myField: " + docs.getResults().get(0).getOnlyField("myField").getText());
}
 
开发者ID:GoogleCloudPlatform,项目名称:java-docs-samples,代码行数:27,代码来源:IndexServlet.java


示例5: testPutGetRangeGetRequest

import com.google.appengine.api.search.GetRequest; //导入依赖的package包/类
@Test
public void testPutGetRangeGetRequest() throws InterruptedException {
    String indexName = "put-index";
    String docId = "testPutDocs";
    Index index = createIndex(indexName, docId);

    GetIndexesRequest request = GetIndexesRequest.newBuilder()
            .setIndexNamePrefix(indexName)
            .build();
    GetResponse<Index> response = searchService.getIndexes(request);
    List<Index> listIndexes = response.getResults();

    for (Index oneIndex : listIndexes) {
        GetResponse<Document> docs = oneIndex.getRange(GetRequest.newBuilder().setStartId(docId + "1").setLimit(10).build());
        sync();
        assertEquals(docs.getResults().size(), 2);
    }
}
 
开发者ID:GoogleCloudPlatform,项目名称:appengine-tck,代码行数:19,代码来源:IndexTest.java


示例6: testPutGetRangeBuilder

import com.google.appengine.api.search.GetRequest; //导入依赖的package包/类
@Test
public void testPutGetRangeBuilder() throws InterruptedException {
    String indexName = "put-index";
    String docId = "testPutDocs";
    Index index = createIndex(indexName, docId);

    GetIndexesRequest request = GetIndexesRequest.newBuilder()
            .setIndexNamePrefix(indexName)
            .build();
    GetResponse<Index> response = searchService.getIndexes(request);
    List<Index> listIndexes = response.getResults();

    for (Index oneIndex : listIndexes) {
        GetResponse<Document> docs = oneIndex.getRange(GetRequest.newBuilder().setStartId(docId + "1").setLimit(10));
        sync();
        assertEquals(docs.getResults().size(), 2);
    }
}
 
开发者ID:GoogleCloudPlatform,项目名称:appengine-tck,代码行数:19,代码来源:IndexTest.java


示例7: testPutGetRangeAsyncGetResponse

import com.google.appengine.api.search.GetRequest; //导入依赖的package包/类
@Test
public void testPutGetRangeAsyncGetResponse() throws InterruptedException, ExecutionException {
    String indexName = "put-index";
    String docId = "testPutDocs";
    Index index = createIndex(indexName, docId);

    GetIndexesRequest request = GetIndexesRequest.newBuilder()
            .setIndexNamePrefix(indexName)
            .build();
    GetResponse<Index> response = searchService.getIndexes(request);
    List<Index> listIndexes = response.getResults();

    for (Index oneIndex : listIndexes) {
        Future<GetResponse<Document>> futurDocs = oneIndex.getRangeAsync(GetRequest.newBuilder().setStartId(docId + "1").setLimit(10).build());
        sync();
        assertEquals(futurDocs.get().getResults().size(), 2);
    }
}
 
开发者ID:GoogleCloudPlatform,项目名称:appengine-tck,代码行数:19,代码来源:IndexTest.java


示例8: testPutGetRangeAsyncBuilder

import com.google.appengine.api.search.GetRequest; //导入依赖的package包/类
@Test
public void testPutGetRangeAsyncBuilder() throws InterruptedException, ExecutionException {
    String indexName = "put-index";
    String docId = "testPutDocs";
    Index index = createIndex(indexName, docId);

    GetIndexesRequest request = GetIndexesRequest.newBuilder()
            .setIndexNamePrefix(indexName)
            .build();
    GetResponse<Index> response = searchService.getIndexes(request);
    List<Index> listIndexes = response.getResults();

    for (Index oneIndex : listIndexes) {
        Future<GetResponse<Document>> futurDocs = oneIndex.getRangeAsync(GetRequest.newBuilder().setStartId(docId + "1").setLimit(10));
        sync();
        assertEquals(futurDocs.get().getResults().size(), 2);
    }
}
 
开发者ID:GoogleCloudPlatform,项目名称:appengine-tck,代码行数:19,代码来源:IndexTest.java


示例9: doGet

import com.google.appengine.api.search.GetRequest; //导入依赖的package包/类
@Override
public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException {
  PrintWriter out = resp.getWriter();
  Document document =
      Document.newBuilder()
          .setId("AZ125")
          .addField(Field.newBuilder().setName("myField").setText("myValue"))
          .build();
  try {
    Utils.indexADocument(INDEX, document);
  } catch (InterruptedException e) {
    out.println("Interrupted");
    return;
  }
  out.println("Indexed a new document.");
  // [START get_document]
  IndexSpec indexSpec = IndexSpec.newBuilder().setName(INDEX).build();
  Index index = SearchServiceFactory.getSearchService().getIndex(indexSpec);

  // Fetch a single document by its  doc_id
  Document doc = index.get("AZ125");

  // Fetch a range of documents by their doc_ids
  GetResponse<Document> docs =
      index.getRange(GetRequest.newBuilder().setStartId("AZ125").setLimit(100).build());
  // [END get_document]
  out.println("myField: " + docs.getResults().get(0).getOnlyField("myField").getText());
}
 
开发者ID:GoogleCloudPlatform,项目名称:java-docs-samples,代码行数:29,代码来源:IndexServlet.java


示例10: verifyDocCount

import com.google.appengine.api.search.GetRequest; //导入依赖的package包/类
private void verifyDocCount(Index index, int docCount) {
    if (docCount == -1) {
        String name = index.getName();
        docCount = Integer.valueOf(name.substring(name.length() - 1));
    }
    List<Document> docList = index.getRange(GetRequest.newBuilder().build()).getResults();
    assertEquals(docCount, docList.size());
}
 
开发者ID:GoogleCloudPlatform,项目名称:appengine-tck,代码行数:9,代码来源:IndexTest.java


示例11: removeAllDocumentsFromIndex

import com.google.appengine.api.search.GetRequest; //导入依赖的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


示例12: getDocumentIds

import com.google.appengine.api.search.GetRequest; //导入依赖的package包/类
private List<Document> getDocumentIds(Index index, GetRequest request) {
    return index.getRange(request).getResults();
}
 
开发者ID:n15g,项目名称:spring-boot-gae,代码行数:4,代码来源:SearchServiceImpl.java



注:本文中的com.google.appengine.api.search.GetRequest类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java ECKeyPair类代码示例发布时间:2022-05-22
下一篇:
Java ProjectData类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap