繁体   English   中英

Google App Engine:未找到API包“搜索”或调用“ IndexDocument()”

[英]Google App Engine: The API package 'search' or call 'IndexDocument()' was not found

我正在尝试使用Google App Engine的Search API将某些文档编入测试索引。 我正在使用Google App Engine官方文档中给出的代码示例。 但是,当我尝试运行以下代码段时。 我通过index.put放置文档时收到以下错误:

线程“主” com.google.apphosting.api.ApiProxy $ CallNotFoundException中的异常:找不到API包“搜索”或调用“ IndexDocument()”。 在com.google.apphosting.api.ApiProxy $ 1.get(ApiProxy.java:179)在com.google.apphosting.api.ApiProxy $ 1.get(ApiProxy.java:177)在com.google.appengine.api.utils com.google.appengine.api.utils.FutureWrapper.get(FutureWrapper.java:88)的.FutureWrapper.get(FutureWrapper.java:88)com.google.appengine.api.search.FutureHelper.getInternal(FutureHelper.java) :73),位于com.google.appengine.api.search.IndexImpl.put(IndexImpl.java:486)的com.google.appengine.api.search.FutureHelper.quietGet(FutureHelper.java:32)。 SearchingService.indexADocument(SearchingService.java:52)

这是代码片段:

 IndexSpec indexSpec = IndexSpec.newBuilder().setName(indexName).build();

          SearchService service = SearchServiceFactory.getSearchService(
                   SearchServiceConfig.newBuilder().setDeadline(10.0).setNamespace("geeky").build());
          Index index = service.getIndex(indexSpec);



          final int maxRetry = 3;
          int attempts = 0;
          int delay = 2;
          while (true) {
            try {

              index.put(document); // ERROR!!!!!!!!!!
            } catch (PutException e) {
              if (StatusCode.TRANSIENT_ERROR.equals(e.getOperationResult().getCode())
                  && ++attempts < maxRetry) { // retrying
                Thread.sleep(delay * 1000);
                delay *= 2; // easy exponential backoff
                continue;
              } else {
                throw e; // otherwise throw
              }
            }
            break;
          }

        }

我在Eclipse Kepler中使用appengine-java-sdk-1.9.18。 我是在本地开发服务器上运行还是在appspot上托管的生产中运行代码都没有关系。 我犯了同样的错误。 我已经在eclipse中通过了我的Google帐户的身份验证,并且能够通过eclipse将我的代码推入生产环境。 有人看过这个错误吗?

因此,在尝试调用Search API时需要注意的事情很少。 安装程序中的第一个错误是我正在使用旧版本的GAE SDK(1.9.18)。

解决此问题后,尝试对文档建立索引时仍然出现错误。 我有从appengine上下文调用的搜索查询功能,但由于它是从“ main”功能运行的,因此我的索引编制引起了相同的错误。 应该始终在appengine上下文中运行Search API的所有功能。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM