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

Java GetResponse类代码示例

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

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



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

示例1: removeAll

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

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


示例3: doGet

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


示例4: testGetIndexes

import com.google.appengine.api.search.GetResponse; //导入依赖的package包/类
@Test
public void testGetIndexes() throws InterruptedException, ParseException {
    String indexName = "indextest";
    addData(indexName);
    GetIndexesRequest request = GetIndexesRequest.newBuilder()
        .setIndexNamePrefix(indexName)
        .setOffset(0)
        .setLimit(10)
        .build();
    GetResponse<Index> response = searchService.getIndexes(request);
    List<Index> listIndexes = response.getResults();
    assertEquals(2, listIndexes.size());

    for (Index oneIndex : listIndexes) {
        String name = oneIndex.getName();
        assertTrue(name.startsWith(indexName));
        verifyDocCount(oneIndex, -1);
    }
}
 
开发者ID:GoogleCloudPlatform,项目名称:appengine-tck,代码行数:20,代码来源:IndexTest.java


示例5: testPutGetRangeGetRequest

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

import com.google.appengine.api.search.GetResponse; //导入依赖的package包/类
@Test
public void testSearchAsyncQuery() throws ExecutionException, 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) {
        QueryOptions.Builder optionBuilder = QueryOptions.newBuilder();
        optionBuilder.setLimit(10);
        Query.Builder queryBuilder = Query.newBuilder().setOptions(optionBuilder.build());
        Future<Results<ScoredDocument>> Fres = oneIndex.searchAsync(queryBuilder.build(""));

        Iterator<ScoredDocument> it = Fres.get().iterator();
        assertEquals(docId + "1", it.next().getId());
        assertEquals(docId + "2", it.next().getId());
        sync();
    }
}
 
开发者ID:GoogleCloudPlatform,项目名称:appengine-tck,代码行数:25,代码来源:SearchServiceTest.java


示例10: testGetIndexesAsyncBuilder

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

    GetIndexesRequest.Builder builder = GetIndexesRequest.newBuilder()
            .setIndexNamePrefix(indexName);

    Future<GetResponse<Index>> response = searchService.getIndexesAsync(builder);
    List<Index> listIndexes = response.get().getResults();

    for (Index oneIndex : listIndexes) {
        Future<Results<ScoredDocument>> Fres = oneIndex.searchAsync("");

        Iterator<ScoredDocument> it = Fres.get().iterator();
        assertEquals(docId + "1", it.next().getId());
        assertEquals(docId + "2", it.next().getId());
        sync();
    }
}
 
开发者ID:GoogleCloudPlatform,项目名称:appengine-tck,代码行数:22,代码来源:SearchServiceTest.java


示例11: testGetIndexesAsyncRequest

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

    GetIndexesRequest request = GetIndexesRequest.newBuilder()
            .setIndexNamePrefix(indexName)
            .build();

    Future<GetResponse<Index>> response = searchService.getIndexesAsync(request);
    List<Index> listIndexes = response.get().getResults();

    for (Index oneIndex : listIndexes) {
        Future<Results<ScoredDocument>> Fres = oneIndex.searchAsync("");

        Iterator<ScoredDocument> it = Fres.get().iterator();
        assertEquals(docId + "1", it.next().getId());
        assertEquals(docId + "2", it.next().getId());
        sync();
    }
}
 
开发者ID:GoogleCloudPlatform,项目名称:appengine-tck,代码行数:23,代码来源:SearchServiceTest.java


示例12: testSearchAsyncString

import com.google.appengine.api.search.GetResponse; //导入依赖的package包/类
@Test
public void testSearchAsyncString() throws ExecutionException, 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) {
        Future<Results<ScoredDocument>> rRes = oneIndex.searchAsync("");

        Iterator<ScoredDocument> it = rRes.get().iterator();
        assertEquals(docId + "1", it.next().getId());
        assertEquals(docId + "2", it.next().getId());
        sync();
    }
}
 
开发者ID:GoogleCloudPlatform,项目名称:appengine-tck,代码行数:22,代码来源:SearchServiceTest.java


示例13: testSearchServiceConfig

import com.google.appengine.api.search.GetResponse; //导入依赖的package包/类
@Test
public void testSearchServiceConfig() throws ExecutionException, InterruptedException {
    String indexName = "put-index";
    String docId = "testPutDocs";
    searchService = SearchServiceFactory.getSearchService(SearchServiceConfig.newBuilder().setDeadline(10.).build());

    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) {
        Results<ScoredDocument> res = oneIndex.search("");

        Iterator<ScoredDocument> it = res.iterator();
        assertEquals(docId + "1", it.next().getId());
        assertEquals(docId + "2", it.next().getId());
        sync();
    }
}
 
开发者ID:GoogleCloudPlatform,项目名称:appengine-tck,代码行数:24,代码来源:SearchServiceTest.java


示例14: doGet

import com.google.appengine.api.search.GetResponse; //导入依赖的package包/类
@Override
public void doGet(HttpServletRequest req, HttpServletResponse resp)
    throws IOException {
  PrintWriter out = resp.getWriter();
  Document doc = Document.newBuilder()
      .setId("theOnlyCar")
      .addField(Field.newBuilder().setName("maker").setText("Toyota"))
      .addField(Field.newBuilder().setName("price").setNumber(300000))
      .addField(Field.newBuilder().setName("color").setText("lightblue"))
      .addField(Field.newBuilder().setName("model").setText("Prius"))
      .build();
  try {
    Utils.indexADocument(SEARCH_INDEX, doc);
  } catch (InterruptedException e) {
    // ignore
  }
  // [START list_schema]
  GetResponse<Index> response = SearchServiceFactory.getSearchService().getIndexes(
      GetIndexesRequest.newBuilder().setSchemaFetched(true).build());

  // List out elements of each Schema
  for (Index index : response) {
    Schema schema = index.getSchema();
    for (String fieldName : schema.getFieldNames()) {
      List<FieldType> typesForField = schema.getFieldTypes(fieldName);
      // Just printing out the field names and types
      for (FieldType type : typesForField) {
        out.println(index.getName() + ":" + fieldName + ":" + type.name());
      }
    }
  }
  // [END list_schema]
}
 
开发者ID:GoogleCloudPlatform,项目名称:java-docs-samples,代码行数:34,代码来源:SchemaServlet.java


示例15: doGet

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


示例16: doGet

import com.google.appengine.api.search.GetResponse; //导入依赖的package包/类
@Override
public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException {
  PrintWriter out = resp.getWriter();
  Document doc =
      Document.newBuilder()
          .setId("theOnlyCar")
          .addField(Field.newBuilder().setName("maker").setText("Toyota"))
          .addField(Field.newBuilder().setName("price").setNumber(300000))
          .addField(Field.newBuilder().setName("color").setText("lightblue"))
          .addField(Field.newBuilder().setName("model").setText("Prius"))
          .build();
  try {
    Utils.indexADocument(SEARCH_INDEX, doc);
  } catch (InterruptedException e) {
    // ignore
  }
  // [START list_schema]
  GetResponse<Index> response =
      SearchServiceFactory.getSearchService()
          .getIndexes(GetIndexesRequest.newBuilder().setSchemaFetched(true).build());

  // List out elements of each Schema
  for (Index index : response) {
    Schema schema = index.getSchema();
    for (String fieldName : schema.getFieldNames()) {
      List<FieldType> typesForField = schema.getFieldTypes(fieldName);
      // Just printing out the field names and types
      for (FieldType type : typesForField) {
        out.println(index.getName() + ":" + fieldName + ":" + type.name());
      }
    }
  }
  // [END list_schema]
}
 
开发者ID:GoogleCloudPlatform,项目名称:java-docs-samples,代码行数:35,代码来源:SchemaServlet.java


示例17: getIndexesNames

import com.google.appengine.api.search.GetResponse; //导入依赖的package包/类
public String[] getIndexesNames() {
	List<String> result=new ArrayList<String>();
	GetResponse<Index> response = SearchServiceFactory.getSearchService().getIndexes(
		    GetIndexesRequest.newBuilder().build());
	List<Index> results = response.getResults();
	for(Index i : results) {
		result.add(i.getName());
	}
	return result.toArray(new String[result.size()]);
}
 
开发者ID:dvorka,项目名称:coaching-notebook,代码行数:11,代码来源:GaeFts.java


示例18: testNamespaceWithBug

import com.google.appengine.api.search.GetResponse; //导入依赖的package包/类
@Test
public void testNamespaceWithBug() throws InterruptedException, ParseException {
    String ns = "ns-indextest";
    String indexName = "ns-index";
    int docCount = 5;
    NamespaceManager.set(ns);
    SearchService searchService2 = SearchServiceFactory.getSearchService();
    Index index = searchService2.getIndex(IndexSpec.newBuilder()
            .setName(indexName)
            .build());
    delDocs(index);
    addDocs(index, docCount);

    GetIndexesRequest request = GetIndexesRequest.newBuilder()
        .setIndexNamePrefix(indexName)
        .setOffset(0)
        .setNamespace(ns)
        .setLimit(10)
        .build();
    assertEquals(ns, request.getNamespace());
    GetResponse<Index> response = searchService2.getIndexes(request);
    List<Index> listIndexes = response.getResults();
    for (Index oneIndex : listIndexes) {
        assertEquals(ns, listIndexes.get(0).getNamespace());
        assertEquals(indexName, listIndexes.get(0).getName());
        verifyDocCount(oneIndex, docCount);
    }
    assertEquals(ns, searchService2.getNamespace());
    NamespaceManager.set("");
}
 
开发者ID:GoogleCloudPlatform,项目名称:appengine-tck,代码行数:31,代码来源:IndexTest.java


示例19: testNamespace

import com.google.appengine.api.search.GetResponse; //导入依赖的package包/类
public void testNamespace() throws InterruptedException, ParseException {
    String ns = "ns-indextest";
    String indexName = "ns-index";
    int docCount = 5;
    NamespaceManager.set(ns);
    Index index = searchService.getIndex(IndexSpec.newBuilder()
            .setName(indexName)
            .build());
    delDocs(index);
    addDocs(index, docCount);

    GetIndexesRequest request = GetIndexesRequest.newBuilder()
        .setIndexNamePrefix(indexName)
        .setOffset(0)
        .setNamespace(ns)
        .setLimit(10)
        .build();
    assertEquals(ns, request.getNamespace());
    GetResponse<Index> response = searchService.getIndexes(request);
    List<Index> listIndexes = response.getResults();
    for (Index oneIndex : listIndexes) {
        assertEquals(ns, listIndexes.get(0).getNamespace());
        assertEquals(indexName, listIndexes.get(0).getName());
        verifyDocCount(oneIndex, docCount);
    }
    assertEquals(ns, searchService.getNamespace());
    NamespaceManager.set("");
}
 
开发者ID:GoogleCloudPlatform,项目名称:appengine-tck,代码行数:29,代码来源:IndexTest.java


示例20: testPutDeleteDocs

import com.google.appengine.api.search.GetResponse; //导入依赖的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)));
    }
}
 
开发者ID:GoogleCloudPlatform,项目名称:appengine-tck,代码行数:39,代码来源:IndexTest.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Java NextOccurenceToolbarAction类代码示例发布时间:2022-05-22
下一篇:
Java JBProgressBar类代码示例发布时间: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