使用Google App Engine的Search API,我试图将某些文档编入索引。我正在使用Google App Engine官方文档中提供的代码示例。
但是当我尝试运行下面的代码片段时。当我通过index.put
放置文档时出现以下错误:
线程“main”中的异常com.google.apphosting.api.ApiProxy $ CallNotFoundException:找不到API包'search'或调用'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;
}
}
我在Eclipse Kepler中使用了appengine-java-sdk-1.9.18。如果我在本地开发服务器上或在appspot上托管的生产中运行代码并不重要。我犯了同样的错误。 我已经在eclipse中对我的谷歌帐户进行了身份验证,并且能够通过eclipse将我的代码推送到生产中。有没有人见过这个错误?