-->

在对Java AppEngine上搜索API配额(quotas on appengine searc

2019-06-24 09:05发布

我正在测试用于Java的新应用程序引擎的搜索API和我有下面的代码,试图在索引中添加〜3000个文件:

List<Document> documents = new ArrayList<Document>();
    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)

是否有我可以外接电话设置为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调用配额为20K /天(在这里看到: https://developers.google.com/appengine/docs/java/search/overview#Quotas )。

什么任何想法是怎么回事?

Answer 1:

有几件事情怎么回事。 最重要的,而这一点是将文档中很快予以澄清,搜索API呼叫份额也占添加/更新的文档数。 因此,单一的添加呼叫插入10个文件将减少10你每天的搜索API调用配额。

是的,可以在一个单一的添加通话被索引的文档的最大数量是200元。但是,在这个阶段也有在地方短期突发配额限制你每分钟约100 API调用。

所有上述意味着,至少在目前,这是最安全的不添加每增加请求超过100个文件。 通过任务队列这样做所推荐的吉文也是一个非常不错的主意。



Answer 2:

我认为,(找不到它验证),有一个每分钟配额限制,你应该使用索引队列您的文件,以确保你逐渐对其进行索引。



Answer 3:

文件提到一个每分钟配额也,20K只有13.9每分钟。

https://developers.google.com/appengine/docs/quotas



文章来源: quotas on appengine search api for java