java的appengine search api上的配额 [英] quotas on appengine search api for java

查看:138
本文介绍了java的appengine search api上的配额的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为java测试新的应用程序引擎搜索api,并且我尝试在索引中添加〜3000文档的以下代码:

 列表<文件> documents = new ArrayList< Document>(); 
for(FacebookAlbum album:user.listAllAlbums()){
Document doc = Document.newBuilder()
.setId(album.getId())
.addField(Field。 newBuilder()的setName( 名)。的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);
}

尝试{
//添加所有文档。
getIndex(facebookId).add(documents);
} catch(AddException e){
if(StatusCode.TRANSIENT_ERROR.equals(e.getOperationResult()。getCode())){
// retry adding document
}
}

但是,我收到以下异常:

 从servlet未捕获的异常
java.lang.IllegalArgumentException:文档数3433在com.google.appengine处超过最大值200
。 api.search.IndexImpl.addAsync(IndexImpl.java:196)
在com.google.appengine.api.search.IndexImpl.add(IndexImpl.java:380)
在photomemories.buildIndexServlet.doGet( buildIndexServlet.java:47)

是否有可以插入的文档数量的配额call set to 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();

尝试{
//添加文档。
getIndex(facebookId).add(doc);
} catch(AddException e){
if(StatusCode.TRANSIENT_ERROR.equals(e.getOperationResult()。getCode())){
// retry adding document
}
}

}

我收到以下异常:

  com.google.apphosting.api.ApiProxy $ OverQuotaException:API调用search.IndexDocument()需要比可用配额更多的配额。 
在com.google.apphosting.runtime.ApiProxyImpl $ AsyncApiFuture.success(ApiProxyImpl.java:479)
在com.google.apphosting.runtime.ApiProxyImpl $ AsyncApiFuture.success(ApiProxyImpl.java:382)
在com.google.net.rpc3.client.RpcStub $ RpcCallbackDispatcher $ 1.runInContext(RpcStub.java:786)
在com.google.tracing.TraceContext $ TraceContextRunnable $ 1.run(TraceContext.java: 455)

我认为api调用的配额是20k / day(请参阅 https://developers.google.com/appengine/docs/java/search/overview#配额)。



关于正在发生的事情的任何想法? 这里有几件事情正在进行。最重要的是,这些将在文档中很快得到澄清,Search API Call配额也说明了正在添加/更新的文档数量。因此,插入10个文档的单个添加调用会将您的每日搜索API调用配额减少10个。



是,可以在单个添加中索引的最大文档数电话是200.然而,在这个阶段,还有一个短期爆裂配额,限制你每分钟约100个API电话。



以上所有的意思是,至少现在,最安全的做法是不要为每个添加请求添加超过100个文档。按照Shay的建议,通过Task Queue这样做也是一个非常好的主意。


I am testing the new app engine search api for java and I have the following code that tries to add ~3000 documents on an index:

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
        }
    }

However, I am getting the following exception:

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 there a quota on the number of documents I can insert with an add call set to 200?

If I try to insert one document at a time to the index with the following code:

 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
            }
        }

    }     

I am getting the following exception:

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)

I thought the quota on the api calls was 20k/day (see here: https://developers.google.com/appengine/docs/java/search/overview#Quotas).

Any ideas on what is going on ?

解决方案

There are a few things going on here. Most importantly, and this is something that will be clarified in the documentation very soon, the Search API Call quota also accounts for the number of documents being added/updated. So a single Add call that inserts 10 documents will reduce your daily Search API Call quota by 10.

Yes, the maximum number of documents that may be indexed in a single add call is 200. However, at this stage there is also a short term burst quota in place that limits you to about 100 API calls per minute.

All the above means that, for now at least, it's safest to not add more than 100 documents per Add request. Doing so via Task Queue as recommended by Shay is also a very good idea.

这篇关于java的appengine search api上的配额的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆