使用 Google App Engine 的搜索 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 .FutureWrapper.get(FutureWrapper.java:88) 在 com.google.appengine.api.utils.FutureWrapper.get(FutureWrapper.java:88) 在 com.google.appengine.api.search.FutureHelper.getInternal(FutureHelper.java :73) 在 com.google.appengine.api.search.FutureHelper.quietGet(FutureHelper.java:32) 在 com.google.appengine.api.search.IndexImpl.put(IndexImpl.java:486) 在 test.service。 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;
}
}
我正在将 appengine-java-sdk-1.9.18 与 Eclipse Kepler 一起使用。我是在本地开发服务器上运行代码还是在 apppot 上托管的生产环境中运行代码都没有关系。我犯了同样的错误。我已经在 Eclipse 中通过我的谷歌帐户进行身份验证,并且能够通过 Eclipse 将我的代码推送到生产环境中。以前有人见过这个错误吗?