Я тестирую новый API поиска движка приложения для java, и у меня есть следующий код, который пытается добавить ~3000 документов в индекс:
List documents = new ArrayList();
for (FacebookAlbum album: user.listAllAlbums()) {
Document doc = Document.newBuilder()
.setId(album.getId())
.addField(Field.newBuilder().setName("name").setText(album.getFullName()))
.addField(Field.newBuilder().setName("albumId").setText(album.getAlbumId()))
.addField(Field.newBuilder().setName("createdTime").setDate(Field.date(album.getCreatedTime())))
.addField(Field.newBuilder().setName("updatedTime").setDate(Field.date(album.getUpdatedTime())))
.build();
documents.add(doc);
}
try {
// Add all the documents.
getIndex(facebookId).add(documents);
} catch (AddException e) {
if (StatusCode.TRANSIENT_ERROR.equals(e.getOperationResult().getCode())) {
// retry adding document
}
}
Однако я получаю следующее исключение:
Uncaught exception from servlet
java.lang.IllegalArgumentException: number of documents, 3433, exceeds maximum 200
at com.google.appengine.api.search.IndexImpl.addAsync(IndexImpl.java:196)
at com.google.appengine.api.search.IndexImpl.add(IndexImpl.java:380)
at photomemories.buildIndexServlet.doGet(buildIndexServlet.java:47)
Is есть ли квота на количество документов, которые я могу вставить с вызовом добавления, установленным на 200?
Если я попытаюсь вставить в индекс по одному документу со следующим кодом:
for (FacebookAlbum album: user.listAllAlbums()) {
Document doc = Document.newBuilder()
.setId(album.getId())
.addField(Field.newBuilder().setName("name").setText(album.getFullName()))
.addField(Field.newBuilder().setName("albumId").setText(album.getAlbumId()))
.addField(Field.newBuilder().setName("createdTime").setDate(Field.date(album.getCreatedTime())))
.addField(Field.newBuilder().setName("updatedTime").setDate(Field.date(album.getUpdatedTime())))
.build();
try {
// Add the document.
getIndex(facebookId).add(doc);
} catch (AddException e) {
if (StatusCode.TRANSIENT_ERROR.equals(e.getOperationResult().getCode())) {
// retry adding document
}
}
}
Я получаю следующее исключение:
com.google.apphosting.api.ApiProxy$OverQuotaException: The API call search.IndexDocument() required more quota than is available.
at com.google.apphosting.runtime.ApiProxyImpl$AsyncApiFuture.success(ApiProxyImpl.java:479)
at com.google.apphosting.runtime.ApiProxyImpl$AsyncApiFuture.success(ApiProxyImpl.java:382)
at com.google.net.rpc3.client.RpcStub$RpcCallbackDispatcher$1.runInContext(RpcStub.java:786)
at com.google.tracing.TraceContext$TraceContextRunnable$1.run(TraceContext.java:455)
Я думал, что квота на вызовы API составляет 20 тыс./день (см. здесь: https://developers.google.com/appengine/docs/java/search/overview#Quotas).
Есть идеи, что происходит?