Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/375.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
java appengine搜索api上的配额_Java_Google App Engine_Quotas_Gae Search - Fatal编程技术网

java appengine搜索api上的配额

java appengine搜索api上的配额,java,google-app-engine,quotas,gae-search,Java,Google App Engine,Quotas,Gae Search,我正在测试针对java的新应用程序引擎搜索api,我有以下代码试图在索引上添加~3000个文档: List<Document> documents = new ArrayList<Document>(); for (FacebookAlbum album: user.listAllAlbums()) { Document doc = Document.newBuilder() .setId(album.getId()

我正在测试针对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
        }
    }
添加调用设置为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/天(参见此处:)


有什么想法吗?

我认为(找不到验证)有每分钟配额的限制,您应该使用队列为文档编制索引,以确保逐步为文档编制索引

文件还提到每分钟定额,20k仅为每分钟13.9英镑


这里发生了一些事情。最重要的是,这一点很快会在文档中得到澄清,搜索API调用配额也会说明添加/更新的文档数量。因此,插入10个文档的单个Add调用将使您的每日搜索API调用配额减少10

是的,在一次添加调用中可以索引的文档的最大数量是200。然而,在这个阶段,还有一个短期突发配额,将您限制在每分钟大约100个API调用


所有这些都意味着,至少就目前而言,在每个添加请求中添加不超过100个文档是最安全的。按照Shay的建议,通过任务队列这样做也是一个很好的主意。

使用队列有什么帮助?每个任务的速率限制是多少?没错。限制队列以避免达到配额限制。谷歌在各地都有每分钟(每秒?)的配额。谢谢彼得!通过每次使用一个文档调用add并使用速率限制为2/s的任务队列来添加~3k个文档-默认队列(5/s)的速率达到突发配额。因此,有效的突发速率限制是>=每分钟120个API调用。问题:调用多文档添加与一次调用多个文档添加相比,是否有好处(更快?)?将多个文档批处理到一个添加调用中效率稍高一些。我们最近取消了免费应用程序的每分钟(突发)搜索配额,因此,您现在可以尽可能快地使用20K搜索API调用配额。
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)